#include <Adafruit_NeoPixel.h>
int neopixelpin = 9;
int noofled = 16;
Adafruit_NeoPixel ring = Adafruit_NeoPixel(noofled,neopixelpin);
int ldr = 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);
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 < noofled; i++){
ring.setPixelColor(i,col);
ring.show();
delay(500);
}
}