Foreword: This is only for beginners, if you have known about Arduino and know how to use “Adafruit_NeoPixel.h library”, it’s no use for you reading this article.
This article of Arduino control pixels mainly use the file named “Adafruit_NeoPixel - master”, you can click https://github.com/adafruit/Adafruit_NeoPixel and http://www.tuicool.com/articles/IbaAJbE to download. If you already downloaded this file, Unzip each library, remove the “-master” from the name of the folder then put the files in here!（The IDE path of library file）(Ps:Ok,explain here I think maybe a little idiot, but for the person who just begin to learn,the explanation is very necessary ).
The file is a sealed unction library and mainly use in the following several functions. Then I will take an example to explain several functions being used.
First you should include the header file in the beginning of the program.
#define PIN 6
#define led_numbers 8
This define the pin number connected of pixels in strip and you control the pixels number
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic ‘v1’ (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(led_numbers, PIN, NEO_GRB + NEO_KHZ800);
- In this functions the led_numbers is qty of full color led you want to control, if you want to change the qty,you can modify it here.
- PIN means the port number connecting with the development board, similar to Arduino, you can set which port you want to use.
- About NEO_GRB+NEO_KHZ800 value indicating the type of NeoPixels that are connected, this example just being extra descriptive.If you have a supply of classic “V1” Flora pixels, those require NEO_KHZ400 + NEO_RGB to be passed here.
This function only perform 1step, the strip.begin() prepares to send data to the LED;
For strip.show() is not necessary, that function mainly used for LED output, in this station the pixels no color. This is to initialize all pixels for “off” .
uint32_t color = strip.Color(R, G, B);
if(i==a) strip.setPixelColor(i, color);
else strip.setPixelColor(i, 0);
- strip.Color(R, G, B) sets up the pixels color,you can set up the number of 0-255, the 255 is pixels maximum brightness, for example we can set strip.Color(255, 255, 0) the main is set red and blue color maximum brightness .
- strip.set Pixel Color(i, color) in this function the ‘i’ is the pixels numbers along the strip, in this examples the ‘i’ numbered 0 through 8. If you want the ninth pixels lit you shout set the ’i’ number is 8, this color is set of in the strip.Color(R, G, B), it is a 32-bit that merges the red ,green and blue values. If you want change the color you can change the R,G,B values.
- strip.show(), this function is output once you set up the color,if not have time delay the color appear jumpy station. So suggest if you want the pixels output smoothly, you can give the function are delayed.
To here the function is used by the example is introduced, this program will appear color flow effect.if you change the program a little the result will be changed.For the above explanation is insufficient, please reference https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library. If you interest this components you can clink and download the components data sheet in here http://forum.arduino.cc/index.php?topic=357076.0. More questions, please feel free to let me know. I am more than happy to offer any information you want.