Instructional: Blink an RGB LED with Arduino

December 1, 2013 by
 

When I was at the World’s Maker Faire in NY this past fall, the kind people at Sparkfun gave me several free Arduino’s and WS2811/ws2812 RGB LED breakout kits to give away.

This is a very brief collection of resources needed to get  new users started using a programmable RGB LED. The beauty of these units is their ability to be chained together.

Take a gander at the goods:

Ws2811 / WS2812 RGB Breakout Board


This is actually a prototype board with an Atmel Mega82U

Sparkfun “Arduino Compatable”

 

 

 

 

 

 

 

 

 

 

 

 

And this is what the end product of this tutorial will look like.

Ooooooo the blinky.

WS2811 Breakout board with Arduino


 

 

 

 

 

 

 

 

 

 

 

Setup:

High level overview:  You will be installing the Arduino IDE, copying the neopixel library folder into the arduino libraries folder, then opening the example project file and upload it to the arduino.

You will need the following items:

 

Procedure:

#1
Download and install the latest Arduino environment.


 

 

 

 

 

 

 

 


 

#2
Download the Neo Pixel library.


#3

Install the library by copying it to the correct folder for your Arduino IDE. This varies by operating system. The following instructions are for PC.

Mac holds its files in a different location. Instructions for installing a library on Mac are located here.

Linux users probably won’t be reading this article.

 

For Windows:
Locate your downloaded .zip file and extract it to a folder.



 

#4
Open the folder and change the name of the folder to Adafruit_NeoPixel, removing the  -master, otherwise you will receive an error.


Copy the folder and Paste it into your libraries folder. (My Documents/Arduino/libraries)


#5
Close and re-open the Arduino program



If you receive the following message, you missed step #4


 

 

#6

If all goes as expected, you should be able to open the “strandtest” NeoPixel example code from the File> Examples> menu.


 

You should see the following code: 


 

#7
I would like to call your attention to the comments in the code. They tell you two pieces of information you need to update before uploading your code.
The first is what pin the LED breakout will be connected to.

This is the first line after the include statement:

#define PIN 6

(btw, that is how you use a library, you have to invite it to the party by using the #include.)

We are going to go ahead and hook up the DI pin of the breakout board to digital pin 6. We are going to keep it at pin 6 in the code. If you want to use a different pin number, this is where you would change it.


On the breakout board – DI for Digital In. DO is for digital out.


 

#8
We are going to physically connect the DI (Digital In) to Pin 6 (digital pin 6) on the Arduino.




#9
We will also set up the number of LEDs. In this instance we only have 1 of these breakout boards connected. If we had more than 1, they could be connected in series.

Change this single line of code from a 60 to a 1

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

#10
Verify that the wiring and environment to ensure we do not perform a smoke test.

Connect the USB cable. 
Tech Tip: If this is your first time connecting the Arduino, your computer may have to load or install a driver to allow your computer to communicate with the Arduino. This driver should be included in the Arduino IDE. If you have problems getting the board to be recognized, you’re gonna have a bad time. See here and here for additional troubleshooting and information. Oh and hereCommunication between the Arduino (Atmel Mega328) and the computer is done over a serial connection. Most Arduinos with a USB connection utilize some form of USB to serial adapter. The board I am using in this particular example uses an FTDI chip to do the USB>serial communication for us. Other boards may use another AVR microcontroller or even implement serial directly in code using v-usb.

 

#11
Click tools > Serial Port and select your COM port.


I tested COM3 – no go.

COM8 is our man


#12
Select the board type from the Tools >Board menu. The Sparkfun Redboard that I am using is Arduino Uno compatible.


#13

Click upload.


If it works you will see some LEDs on the Arduino flashing. On mine it was the red and yellow RX /TX LED’s.



Wonder of Wonders, it works!

Prototyping is fun, but we can do better.

 

 

 

 

 

 

 

 

 

 

Troubleshooting:

If you get errors like this when uploading, go back to step #11. You may have to go back and select a different COM port or a different board.




If your board had a few flashes of lights but no activity on the breakout board, double check the 5v, ground, and DI wire are securely connected and plugged in to the correct pins on the Arduino.

 

Going Further:

-Connect multiple WS2811’s in Series

-Connect multiple WS2811’s in a matrix

Alternative Libraries

OCTOWS2811 by PJRC

Neopixel by Adafruit


 

 

This post was composed and uploaded from Microsoft OneNote 2013

Comments

One Comment on Instructional: Blink an RGB LED with Arduino

  1. Y.N on Sun, 9th Mar 2014 11:58 pm
  2. Hey Mr. Havell,

    Do you happen to want to throw away one of those arduinos? If you do, let me know. :)