#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() {
// put your setup code here, to run once:
ring.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
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);
}
}