Who doesn't like to light up a RC plane using fancy LED lights? I think we all do! Especially as the daylight gets shorter and shorter... It not only enables us to fly planes in the night but also make them look cool in air... I am writing this basic [detailed] tutorial on how to implement programmable LEDs to light up our aircrafts and have fun!
1) WS2812B LED lights:
You can buy them in various configurations but most popular for our use would be these three configurations: 30 LEDs/meter, 60 LEDs/meter or 144 LEDs/meter. You can buy them from various sources eBay, Amazon, Bangood, adafruit (neopixel), etc...
** Make sure not to get confused with other models such as WS2801, WS2811, ANALOG single color or ANALOG multicolor RGB LEDs and others... **
2) Arduino Nano:
This is the Arduino board that we'll be using because of its small form factor making it easy to install in planes/drones.
A 100uF - 1000uF capacitor would work well. 1000uF capacitor (16V or 25V are popular) is recommended.
A resistor rated between 200ohm - 470ohm would work well... I am using a 470ohm resistor!
A soldering station, a dedicated 3A-5A BEC is recommended
, LiPo battery, computer with Arduino IDE software
and some patience
1) WS2812b LED lights:
The cool part about these LEDs is you can address each LED individually
in a strip to control the color and the pattern of display. This allows us to create cool designs and effects easily! This is how the strip typically looks like:
Here are some important details about the strips:
-> Shown above in the picture are 3 different configurations of LEDs you can get.
-> There are 3 copper pads between each led unit in the strip:
**The "data input" and "data output" pins are usually in the center if not specified**
- GND or "-": Ground (or common) connection
- Din or Di: Data Input - the data signal to LED is provided thru this connection
- Dout or Do: Data Output - This can be connected directly to "Din" to transfer data to next LED in line
- 5V or "+": Connect +5V Power supply here
-> The LED strips can be trimmed to your required length
by cutting off at the center of the copper pads (as indicated by the red dotted line in the picture above)
-> The direction of data flow
is indicated by the arrow printed on the LED strip (as depicted by yellow box in the picture above) - this also means that we can connect or "chain" multiple strips together by keeping the data flow [arrow pointing for both strips] in same direction... i.e. the "Dout" always connects to "Din"!
-> A single LED/pixel on strip consists of a small chip plus 3 LEDs (emit red, blue or green colors) integrated together. Combination of these 3 colors at different intensities give us different color combinations!
2) Arduino Nano:
This is a small yet powerful board based on the Atmega328p chip for controlling our LEDs. We can program this board via USB cable and using the Arduino IDE software
. This is how it looks like:
Since the power consumption of LED can widely vary depending on the color of each pixel, a 1000uF capacitor connected in parallel with the +5V power and GND will protect the LED strip from damaging!
Note: capacitors have polarity! The "GND" pin on capacitor is indicated by "-" sign... The short length of pin on the capacitor is also an indication of "GND" pin
A small 470ohm resistor should be connected between Arduino's data output and LED's data input connections to help protect the data pin!
5) Power requirements:
A total of 5V is needed to power our LEDs however, each LED/pixel on the strip will consume about 60mA (or 0.06A) of current maximum (when red, blue and green leds within the pixel are all on at max intensities)... That being said we can calculate the current requirements for our project, for e.g.:
-> 1 meter strip with 30 LED/meter = 30 x 0.06A = 1.8A total
-> 1 meter strip with 60 LED/meter = 60 x 0.06A = 3.6A total
-> 1 meter strip with 144 LED/meter = 144 x 0.06A = 8.64A total
So to calculate your power requirements, simply multiply number of LED/pixel you are using by 0.06A
and thats your current requirement. So choose a BEC accordingly! 5A BEC usually is more than enough for most of our projects!
- In menu section, select Sketch -> Include Library -> Manage Libraries.... Type "NeoPixel" in the text box and install "Adafruit NeoPixel by Adafruit"
*if you are unable to install with method above then, download the Adafruit NeoPixel Library. Simply click the "clone or download" button on the upper right side and select "Download Zip". Goto Sketch -> Import Library -> Add Library and select the zip file you just downloaded!
- Connect your Arduino board via USB. Note: Arduino connects with a mini-B USB cable
- In menu section, goto Tools -> "serial port" or "port" and make sure the appropriate COM port is selected (in most cases this should be selected automatically if arduino is the only board connected to your system)
* For Mac users, you can proceed to next steps however, in some windows systems you will not be able to select the com port in which case you need to install the drivers manually! To do so, goto control panel -> device manager. Look for "ports" or "unknown devices" with a yellow exclamation mark! Right click and select "update driver software". Next, choose "Browse my computer for driver software" -> Browse -> goto "C:\Program Files (x86)\Arduino\drivers" and select next to install the drivers
- Select the appropriate board by selecting Tools -> Board, and select "Nano w/ATmega328" or "Arduino Duemilanove"
- To load a test program, GoTo File -> Examples -> Adafruit NeoPixel -> strandtest
- Modify on the code according to your needs:
a) The pin number is where the signal output will be provided and is where your LED signal "Din" connects!
b) Set the number of pixels/LED you have on your strip
- Click on the "tick mark button" (on the upper left corner) to "Verify" the code (you should see a message "done compiling" at the bottom)
- To upload the code to Arduino, select "right arrow button" (next to the verify button). Your Arduino is all set!! You can disconnect the USB connection at this point.
Single pattern on different strips:
The signal output can be reliably given from pins D2 - D13 ("D" stands for digital output). Make sure that the pin # corresponds to the pin # in the software code. Double check to make sure there are no shorts! Below are the detailed connections on not only how to connect LED strip to Arduino but also chaining two strips:
Different patterns on two or more strips:
To control two individual strips differently, the connection diagram below can be used... The "+5V" and the "GND" cables can still be connected like previously shown however, the signal cable is directly connected to a different pin of Arduino. Similarly, more than two connections can be made to control several LED strips...
Once the lipo is connected, the loaded program will start running and at this point you should be able to see the lights operating to the given code. Once the sequence is complete, it will keep repeating until the battery is unplugged. To interrupt and restart the sequence anytime, press the reset button!
Here's how it should look like:
- I really hope that you find this tutorial useful and will hopefully provide some basic understanding of programming LEDs using Arduino.
- Its is really an easy way to bring out the best out of your projects.
- I would highly recommend editing and playing around with the basic framework of code and see what happens/changes.
- Finally, I really hope that this will help develop more creative LED lighting RC projects and make night flying even more fun and enjoyable!