Introduction: Simple Arduino Neopixel Test
Hello instructable
you know the struggle when you write a code for your neopixel leds and you are not sure if your neopixel led is working well or your code is messed up ?
anyway i know this problem,
so i made a little test code to see your leds light up red,green,blue
if you want to make this work you will need:
- an arduino
- adafruit_neopixel.h libary ''hint hint'' -->> Download
- your neopixel leds.
- 5v adapter DC (since we dont want to molest the 5v from your arduino and the neopixel leds tend to ask alot mA
Step 1: Starting Up
first you want to make sure you got the code
This is the code (tadam)
#include
int c = 0; //secret
int r; //red
int g; //green
int b; //blue
# define count 11 // number of leds
# define Pixel 2 // com. pin from your neo pixel
# define p 25 //brightness 0 - 255
# define flow 35 // flow rate from first to last led 1000 = 1 sec
Adafruit_NeoPixel pix = Adafruit_NeoPixel(count, Pixel, NEO_GRB + NEO_KHZ800);
void setup()
{
pix.begin();
for (int a = 0 ;a<=count ; a = a+1)
{
if (a > count-1 && c < 3) {c = c+1; a = -1;}
else if (c == 0) {r = p; g = 0; b = 0; }
else if (c == 1) {r = 0; g = p; b = 0; }
else if (c == 2) {r = 0; g = 0; b = p; }
else if (c == 3) {r = 0; g = 0; b = 0; }
pix.setPixelColor(a,r,g,b);
pix.show();
delay(flow);
}
}
void loop()
{
for (int x =0; x <= count-1 ; x++)
{
pix.setPixelColor(x,p,0,0);
pix.show();
delay(500);
pix.setPixelColor(x,0,0,0);
pix.show();
delay(500);
for (;x==10;x=-1);
{
delay(500);
}
}
}
Step 2: Adjusting the Code
there are some things i can not know , when i was making this
so i made constantes you need to fill in ,those are:
- number of leds (#define count)
- pin on witch your com. is connected (#define Pixel)
- the brightnes (#define p )
in my case the ''settings'' are
- = 11 (#define count 11)
- = 2 (#define Pixel 2)
- = 25 (#define p 25)
Step 3: Wire Up
- disconnect the usb
- connect the 5v- to gnd of your neopixel led and arduino
- connect the 5v+ to the + of your neopixel led and vin of your arduino
- com. from your neopixel led to the choosen pin on the arduino
- Connect the adapter !
the test is just a once flash and as soon its done your neopixel led wil flash red (each led apart)
i hope i helped you guys with this
this was my first instructable
and yes i know my english is very derpy and bad . sorrey and BYE!