All Tutorials / CochranRobotics / NeoPixel Ring with Arduino as control board

NeoPixel Ring with Arduino as control board

Commands sent from the EZ-B to the Arduino

The top portion of the sketch contains all of the commands that the Arduino can accept. Some commands take more parameters than others. Below are the comments that are in the script which outline each command and its needed parameters.

Code:


/ Serial Commands
/ Cr1,g1,b1 - Set whole Ring to same color specified by r1,g1,b1
/ Rt,d - Rainbow with interval t and direction d
/ Tr1,g1,b1,r2,g2,b2,t,d - Theater Chase between color r1,g1,b1 and color r2,g2,b2 with interval t and direction d
/ Wr1,g1,b1,t,d - Color Wipe in color r1,g1,b1 with interval t and direction d
/ Fr1,g1,b1,r2,g2,b2,s,t,d - Fade between color r1,g1,b1 and color r2,g2,b2 in s steps with interval t and direction d
/ Sr1,g1,b1,t - Scanner with color specified by r1,g1,b1 and interval t
/ Pp,r1,g1,b1 - Set individual pixel p to color specified by r1,g1,b1
/
/ p = pixel number
/ r1 = 1st color red values 0 to 255
/ g1 = 1st color greern values 0 to 255
/ b1 = 1st color blue values 0 to 255
/ r2 = 2nd color red values 0 to 255
/ g2 = 2nd color greern values 0 to 255
/ b2 = 2nd color blue values 0 to 255
/ s = number of steps
/ t = interval time values 0 to 255
/ d = direction 0 = Forward 1 = Backward
*/



If you used the wiring section that I provided, you should be able to use this example script in EZ-Builder to run through a few of the different modes for the NeoPixel.

This command will send a serial command from digital pin 5 at 9600 baud of "C100,1,1" which will turn the ring red.

Code:


sendserial( D5, 9600, "C100,1,1")



This command will send a serial command from digital pin 5 at 9600 baud of "R20.0" which will make a rainbow effect.

Code:


sendserial( D5, 9600, "R20,0")



This command will send a serial command from digital pin 5 at 9600 baud of "T100,1,1,1,100,1,20,0" which will make a a theater chase effect.

Code:


sendserial( D5, 9600, "T100,1,1,1,100,1,20,0")



With these examples, you should be able to see how the parameters are passed and used.

To turn off the NeoPixel, just send a command of C0,0,0 to the controller. This sets all pixels to off.

Code:


sendserial( D5, 9600, "C0,0,0")