//AIM- Add a condition in the same code to emit red and green lights from a Neopixel ring based on the condition
#include <Adafruit_NeoPixel.h>
int PIN =12;
int N_LEDS =16; //numbers of LED
Adafruit_NeoPixel ring = Adafruit_NeoPixel(N_LEDS, PIN); //ring is variable
void setup()
{
ring.begin(); //start the functionality
}
void loop()
{
for(int i=0; i<N_LEDS; i++ )
{
ring.setPixelColor(i , ring.Color(0, 0, 255)); // Draw new pixel; blue
ring.show();
delay(500);
if (i<8)
{
ring.setPixelColor(i , ring.Color(255, 0, 0)); // Draw new pixel; red
ring.show();
delay(500);
}
else
{
ring.setPixelColor(i , ring.Color(0, 255, 0)); // Draw new pixel; green
ring.show();
delay(500);
}
}
}