We've connected an addressable RGB LED to our Arduino Uno and successfully got it to display whatever colors we needed. It uses the Adafruit Neopixel library located here: GitHub - adafruit/Adafruit_NeoPixel: Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)
Unfortunately, when we added in code to receive the x, y, and z values from the accelerometer, the led stops working. So we're just trying to figure out why the LED stops working after the analogReads. Any help is appreciated.
here is the code:
#include <Adafruit_NeoPixel.h>
#ifdef AVR
#include <avr/power.h>
#endif
#define PIN 8
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_RGB);
int accel_x, accel_y, accel_z;
int r, g, b;
void setup() {
Serial.begin(9600);
strip.begin();
strip.show();
}
void loop() {
accel_x = analogRead(0);
accel_y = analogRead(1);
accel_z = analogRead(2);
strip.setPixelColor(0, strip.Color(0, 255 , 0));
strip.show();
}