54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#include <Adafruit_NeoPixel.h>
|
|
#ifdef __AVR__
|
|
#include <avr/power.h>
|
|
#endif
|
|
|
|
//Important: Set the number of LEDs here!!!
|
|
#define PIN 6
|
|
#define NUMPIXELS 22
|
|
|
|
//Create the object representation of our strip
|
|
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
|
|
|
//Some usefull variables and buffers, currently not all in use
|
|
unsigned long previousMillis = 0;
|
|
unsigned long interval = 0;
|
|
int mode = 0;
|
|
int element = 0;
|
|
|
|
int colorval1 = 0;
|
|
int colorval2 = 0;
|
|
int colorval3 = 0;
|
|
|
|
|
|
void setup() {
|
|
pixels.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
|
|
if(element<NUMPIXELS)
|
|
element++;
|
|
else
|
|
element = 0;
|
|
|
|
for(int i = 0; i < NUMPIXELS; i++){
|
|
//Set the color values for all leds as pixels.Color(G,R,B);
|
|
pixels.setPixelColor(i,pixels.Color(((i==element)?255 :0),((i==element)?0:0),((i==element)?0:255))); // Moderately bright green color.
|
|
}
|
|
|
|
/*
|
|
for(int i = 0; i < NUMPIXELS; i++){
|
|
if(i%2)pixels.setPixelColor(i,pixels.Color(0,0,255));
|
|
else pixels.setPixelColor(i,pixels.Color(255,0,0));
|
|
}
|
|
*/
|
|
//this sends the data from our object to the actuall strip
|
|
pixels.show();
|
|
delay(200);
|
|
}
|