Devices & Components
Arduino Nano
NeoPixel Ring: WS2812 5050 RGB LED
Project description
Code
untitled
c_cpp
1#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels 2 3void 4 setup() { 5 // These lines are specifically to support the Adafruit Trinket 5V 6 16 MHz. 7 // Any other board, you can remove this part (but no harm leaving it): 8#if 9 defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 10 clock_prescale_set(clock_div_1); 11#endif 12 13 // END of Trinket-specific code. 14 15 pixels.begin(); // INITIALIZE NeoPixel 16 strip object (REQUIRED) 17} 18 19void loop() { 20 pixels.clear(); // Set all 21 pixel colors to 'off' 22 23 // The first NeoPixel in a strand is #0, second is 24 1, all the way up 25 // to the count of pixels minus one. 26 for(int i=0; i<NUMPIXELS; 27 i++) { // For each pixel... 28 29 // pixels.Color() takes RGB values, from 30 0,0,0 up to 255,255,255 31 // Here we're using a moderately bright green color: 32 33 pixels.setPixelColor(i, pixels.Color(0, 150, 0)); 34 35 pixels.show(); 36 // Send the updated pixel colors to the hardware. 37 38 delay(DELAYVAL); 39 // Pause before next pass through loop 40 } 41}
untitled
c_cpp
1#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels 2 3void setup() { 4 // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 5 // Any other board, you can remove this part (but no harm leaving it): 6#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 7 clock_prescale_set(clock_div_1); 8#endif 9 // END of Trinket-specific code. 10 11 pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) 12} 13 14void loop() { 15 pixels.clear(); // Set all pixel colors to 'off' 16 17 // The first NeoPixel in a strand is #0, second is 1, all the way up 18 // to the count of pixels minus one. 19 for(int i=0; i<NUMPIXELS; i++) { // For each pixel... 20 21 // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255 22 // Here we're using a moderately bright green color: 23 pixels.setPixelColor(i, pixels.Color(0, 150, 0)); 24 25 pixels.show(); // Send the updated pixel colors to the hardware. 26 27 delay(DELAYVAL); // Pause before next pass through loop 28 } 29}
Downloadable files
bandicam_2019-10-08_02-25-31-497_qNyOAGJaIO.jpg
bandicam_2019-10-08_02-25-31-497_qNyOAGJaIO.jpg

bandicam_2019-10-08_02-25-31-497_qNyOAGJaIO.jpg
bandicam_2019-10-08_02-25-31-497_qNyOAGJaIO.jpg

Comments
Only logged in users can leave comments