#include <Adafruit_NeoPixel.h>
int NeoPixel_PIN = 9;
int N_LEDS = 16;
Adafruit_NeoPixel ring = Adafruit_NeoPixel(N_LEDS, NeoPixel_PIN);
int LDR_PIN = A0;
int value = 0;
void setup() {
ring.begin();
Serial.begin(9600);
}
void loop() {
value = analogRead(LDR_PIN);
Serial.println(value);
if (value > 1000)
{
Serial.println("Red");
set_color(ring.Color(255, 0, 0));
}
else if (value > 500)
{
Serial.println("Yellow");
set_color(ring.Color(255, 255, 0));
}
else
{
Serial.println("Green");
set_color(ring.Color(0, 255, 0));
}
}
int set_color(uint32_t col)
{
for(int i=0; i<N_LEDS; i++)
{
ring.setPixelColor(i, col);
ring.show();
delay(500);
}
}