Instructional: Blink an RGB LED with Arduino
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:
And this is what the end product of this tutorial will look like.
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:
- WS2811 Breakout Board
- Arduino or Arduino compatible board
- Arduino Programming environment
- The Adafruit Neo Pixel library
- A USB cable
Download and install the latest Arduino environment.
Download the Neo Pixel library.
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.
Locate your downloaded .zip file and extract it to a folder.
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)
Close and re-open the Arduino program
If you receive the following message, you missed step #4
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:
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.
We are going to physically connect the DI (Digital In) to Pin 6 (digital pin 6) on the Arduino.
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);
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 here. Communication 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.
Click tools > Serial Port and select your COM port.
I tested COM3 – no go.
COM8 is our man
Select the board type from the Tools >Board menu. The Sparkfun Redboard that I am using is Arduino Uno compatible.
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!
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.
-Connect multiple WS2811’s in a matrix
This post was composed and uploaded from Microsoft OneNote 2013