library documentation
https://adafruit.github.io/Adafruit_NeoPixel/html/index.html
Each individual NeoPixel draws up to 60 milliamps at maximum brightness white (red + green + blue). In actual use though, it’s rare for all pixels to be turned on that way. When mixing colors and displaying animations, the current draw will be much less. It’s impossible to estimate a single number for all circumstances, but we’ve been using 1/3 this (20 mA per pixel) as a gross rule of thumb with no ill effects. But if you know for a fact that you need every pixel on at maximum brightness, use the full 60 mA figure.
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 35 36 37 38 39 |
/* NeoPixel LEDs modified on 7 May 2019 by Saeed Hosseini @ Electropeak **This code is based on Adafruit NeoPixel library Example** https://electropeak.com/learn/ */ #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> // Required for 16 MHz Adafruit Trinket #endif #define PIN D3 #define NUMPIXELS 7 Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); #define DELAYVAL 500 // Time (in milliseconds) to pause between pixels void setup() { pixels.begin(); } void loop() { pixels.clear(); pixels.setBrightness(10); pixels.setPixelColor(0, pixels.Color(255, 255, 255)); pixels.setPixelColor(1, pixels.Color(255, 0, 0)); pixels.setPixelColor(2, pixels.Color(0, 255, 0)); pixels.setPixelColor(3, pixels.Color(0, 0, 255)); pixels.setPixelColor(4, pixels.Color(255, 0, 255)); pixels.setPixelColor(5, pixels.Color(255, 255, 0)); pixels.setPixelColor(6, pixels.Color(0, 255, 255)); pixels.show(); } |
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 35 36 37 38 39 40 41 |
/* NeoPixel LEDs modified on 7 May 2019 by Saeed Hosseini @ Electropeak https://electropeak.com/learn/ */ #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> // Required for 16 MHz Adafruit Trinket #endif #define PIN D3 #define NUMPIXELS 7 Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); #define DELAYVAL 500 // Time (in milliseconds) to pause between pixels void NeoFade(int FadeSpeed) { int fspeed; for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, 165, 242, 243); } for (int j = 255; j > 0; j=j-2) { pixels.setBrightness(j); pixels.show(); delay(FadeSpeed); } } void setup() { pixels.begin(); } void loop() { NeoFade(100); } |