Thumbstick codes working again
Just a short example of making a nice swirly light with the neopixel and using arrays to set brightness/color. Hopefully the video works, Roberto is watching in the background
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | //A slow moving demo of the neopixels #include <Adafruit_NeoPixel.h> #define PIN 6 Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800); int brgt[]={10,20,50,100,255}; //Array of brightness settings int temppin=0; int pix[]={255,23,222,34,88}; //array of colors void setup() { strip.begin(); //start the neopixel strip.show(); //turn all pixels off // Serial.begin(9600); } void loop() { for(int j=0;j<=15;j++){ strip.setBrightness(0); //turns off the pixels, without this they stay lit, set it to 50 and see strip.show(); for(int i=0;i<5;i++){ strip.setPixelColor(j,255,0,pix[i]); //looping through all the color settings strip.setBrightness(brgt[i]); //looping through all the brightness settings strip.show(); //needed to update the pixels temppin=j-1; strip.setPixelColor(temppin,255,0,10); //this turns on the previous pixel, as pixel j is displayed, j-1 is lit. Move this outside the loop and it'll change things delay(10); //the delay between each brightness setting } } } |