Created
September 18, 2019 10:32
-
-
Save IsmailSan/6aa6f115a4a44de4d0c5a66d454a1a69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <ESPectro32_Board.h> | |
#include <ESPectro32_RGBLED_Animation.h> | |
#include "SparkFunLSM6DS3.h" | |
#include "Wire.h" | |
#include "SPI.h" | |
RgbLedColor_t aCol(200, 0, 0); | |
RgbLedColor_t bCol(0, 200, 0); | |
RgbLedColor_t cCol(0, 0, 200); | |
ESPectro32_RGBLED_GlowingAnimation glowAnim1(ESPectro32.RgbLed(), aCol); | |
ESPectro32_RGBLED_GlowingAnimation glowAnim2(ESPectro32.RgbLed(), bCol); | |
ESPectro32_RGBLED_GlowingAnimation glowAnim3(ESPectro32.RgbLed(), cCol); | |
LSM6DS3 myIMU; | |
float X, Y, Z = 0; | |
void setup() { | |
Serial.begin(9600); | |
myIMU.begin(); | |
} | |
void loop() | |
{ | |
X = myIMU.readFloatAccelX(); | |
Y = myIMU.readFloatAccelY(); | |
Z = myIMU.readFloatAccelZ(); | |
if (X > 0.80) { | |
glowAnim1.start(); | |
} | |
if (Y > 0.80) { | |
glowAnim2.start(); | |
} | |
if (Z < -0.90) { | |
glowAnim3.start(); | |
} | |
Serial.print("X :"); | |
Serial.print(X); | |
Serial.print("\t"); | |
Serial.print("Y :"); | |
Serial.print(Y); | |
Serial.print("\t"); | |
Serial.print("Z :"); | |
Serial.println(Z); | |
Serial.print("\t"); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment