| Zakładka z wyszukiwarką danych komponentów |
|
WS2812 Arkusz danych(PDF) 56 Page - Raspberry Pi Holdings PLC |
|
|
|||||||||||||||||||||||||||||
WS2812 Arkusz danych(HTML) 56 Page - Raspberry Pi Holdings PLC |
|
56 / 98 page ![]() Then, in the setup() function, call begin() to prepare the data pin for NeoPixel output: void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' } The second line, strip.show(), isn’t absolutely necessary, it’s just there to be thorough. That function pushes data out to the pixels…since no colors have been set yet, this initializes all the NeoPixels to an initial “off” state in case some were left lit by a prior program. In the strandtest example, loop() doesn’t set any pixel colors on its own — it calls other functions that create animated effects. So let’s ignore it for now and look ahead, inside the individual functions, to see how the strip is controlled. There are a couple different ways to set the color of a pixel. The first is: strip.setPixelColor(n, red, green, blue); or, if you're using RGBW strips: strip.setPixelColor(n, red, green, blue, white); The first argument — n in this example — is the pixel number along the strip, starting from 0 closest to the Arduino. If you have a strip of 30 pixels, they’re numbered 0 through 29. It’s a computer thing. You’ll see various places in the code using a for loop, passing the loop counter variable as the pixel number to this function, to set the values of multiple pixels. The next three arguments are the pixel color, expressed as red, green and blue brightness levels, where 0 is dimmest (off) and 255 is maximum brightness. The last optional argument is for white, which will only be used if the strip was defined during creation as an RGBW type and the strip actually is RGBW type. To set the 12th pixel (#11, counting from 0) to magenta (red + blue), you could write: strip.setPixelColor(11, 255, 0, 255); to set the 8th pixel (#7 counting from 0) to half-brightness white (with an RGBW strip), with no light from red/green/blue, use: strip.setPixelColor(7, 0, 0, 0, 127); An alternate syntax has just two arguments: LEDs use NEO_RGBW (some RGBW strips use NEO_GRBW, so try that if you're getting unexpected results!) The Adafruit Trinket 5V 16 MHz board requires a little extra setup. You can see the steps required in the “strandtest” example sketch. © Adafruit Industries https://learn.adafruit.com/adafruit-neopixel-uberguide Page 59 of 101 |
|
Link URL |
| Czy Alldatasheet okazała się pomocna? [ DONATE ] |
O Alldatasheet | Reklama | Kontakt | Polityka prywatności | Link do karty katalogowej | Linki | Lista producentów All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |