/***********************************************************************
write c plus code using arduino and neopixle ring having 24 leds in
such a way that all leds chase in different random colors clockwise
then chase anticlock wise with different colors,then blink all leds
three time with three times usin all leds color red, green, yellow
.repeate with voide loop
In this code, we use the Adafruit NeoPixel library to control the
NeoPixel Ring. In the setup function, we initialize the strip object
and set all the pixels to off using the show method. In the loop
function, we implement the three behaviors you described.
First, we chase the LEDs clockwise and anticlockwise with random
colors using two for loops and the setPixelColor and show methods
of the strip object.
Next, we blink all the LEDs three times with different colors using
another for loop and the setPixelColor and show methods. We set the
color of all LEDs to red, green, and yellow in sequence using the RGB
color values (255,0,0), (0,255,0), and (255,255,0), respectively.
Finally, we repeat the entire sequence by going back to the
beginning of the loop function. The delay functions are used
to control the timing of the animations.
author arvind patil 18 march2013
***********************************************************************/
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_LEDS 24
Adafruit_NeoPixel strip(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Chase clockwise with random colors
for(int i=0; i<NUM_LEDS; i++) {
strip.setPixelColor(i, random(256), random(256), random(256));
strip.show();
delay(50);
}
// Chase anticlockwise with random colors
for(int i=NUM_LEDS-1; i>=0; i--) {
strip.setPixelColor(i, random(256), random(256), random(256));
strip.show();
delay(50);
}
// Blink all LEDs with different colors
for(int c=0; c<3; c++) {
for(int i=0; i<NUM_LEDS; i++) {
strip.setPixelColor(i, 255, 0, 0); // red
}
strip.show();
delay(500);
for(int i=0; i<NUM_LEDS; i++) {
strip.setPixelColor(i, 0, 255, 0); // green
}
strip.show();
delay(500);
for(int i=0; i<NUM_LEDS; i++) {
strip.setPixelColor(i, 255, 255, 0); // yellow
}
strip.show();
delay(500);
}
}