Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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