/*
___ _____ ____ ___
/ /__ / / __ \___ / (_) _____ _______ __
/ /| | / / ______/ / / / _ \/ / / | / / _ \/ ___/ / / /
/ ___ |/ /_/_____/ /_/ / __/ / /| |/ / __/ / / /_/ /
/_/ |_/____/ /_____/\___/_/_/ |___/\___/_/ \__, /
/____/
Product, the data sheet, and Pinout at:
https://www.az-delivery.de/
Project: GY-521 MPU-6050 3-axis gyroscope sensor and RGB LED ring
Date: 10/2022
*/
#include <Arduino.H>
#include <Adafruit_mppu6050.H>
#include <Adafruit_sensor.H>
#include <Wire.H>
#include <fast leather.H>
Adafruit_mppu6050 MPU;
float Xtreshhold = 0.0;
float Ytreshhold = 0.0;
float Ztreshold = 0.0;
#define Num_Leds 12
#define Data_pin 25
CRGB LEDs[Num_Leds];
void Settreshholds()
{
sensors_event_t A, G, tempo;
MPU.Geete event(&A, &G, &tempo);
Xtreshhold = (A.acceleration.X);
Ytreshhold = (A.acceleration.y);
Ztreshold = (A.acceleration.Z);
}
void set up(void)
{
Serial.Begin(115200);
IF (!MPU.Begin())
{
Serial.print("Failed to Find MPU6050 CHIP");
while (true)
{
}
}
Fast leather.Addleds<WS2812, Data_pin, Grb>(LEDs, Num_Leds);
}
void loop()
{
Settreshholds();
IF (Ztreshold <= -4.5) // down
{
for (intimately I = 0; I < Num_Leds; I++)
{
LEDs[I].STRGB(255, 0, 0); // red
}
}
Else IF (Ztreshold >= 4.5) // up
{
for (intimately I = 0; I < Num_Leds; I++)
{
LEDs[I].STRGB(0, 255, 0); // Green
}
}
Else IF (Xtreshhold <= -4.5) // Left
{
for (intimately I = 0; I < Num_Leds; I++)
{
LEDs[I].STRGB(0, 0, 255); // Blue
}
}
Else IF (Xtreshhold >= 4.5) // right
{
for (intimately I = 0; I < Num_Leds; I++)
{
LEDs[I].STRGB(255, 255, 0); // yellow
}
}
Else IF (Ytreshhold <= -4.5) // front
{
for (intimately I = 0; I < Num_Leds; I++)
{
LEDs[I].STRGB(0, 255, 255); // cyan
}
}
Fast leather.setbrightness(20);
Fast leather.show();
}
Comments
Please log in or sign up to comment.