USA flag constructed using a total of 2,301 diffused red, white and blue LEDs completed with Arduino sketch animations, I hope this instructions helps anyone who wants to try this out. This flag can be displayed during the 4th of July, memorial day or during Christmas. If you find this project interesting and you do something similar by making either the hardware or the Arduino software codes better, please share with others.
Below is the You Tube video of the finished flag.
Step 1: Materials and Tools
Here is a list of materials and tools I used for this
- Polystyrene plastic sheet (0.125" thickness; Quantity: 1)
($21 + $12.35 shipping US):
- 5mm Red Diffused LED (Quantity: 1000)
($16.52 for 1000 free shipping from China):
- 5mm White Diffused LED (Quantity: 1000)
($22.40 for 1000 free shipping from China):
- 5mm Blue Diffused LED (Quantity: 500)
($11.91 for 500 free shipping from China):
- Arduino Mega 2560
($14.96 free shipping US)
- N-Cannel MOSFET (Quantity: 15)
($12.13+ $3.09 shipping US)
- 12V 5A Power Supply (Quantity: 1)
($15.99 free shipping US):
- Prototype board (Quantity: 1)
Obtained at a local Radioshark at $3.49
- 100 ohms Resistors (Quantity: 975)
Obtained at a local component store $0.03/resistor
- 220 ohms Resistors (Quantity: 50)
Obtained at a local component store $0.03/resistor
- Soldering iron
- Solder lead
- Drill Press (This will make it a lot easier and accurate drilling than hand drill)
- Needle-nose pliers
- Tape measure
- Pencil to mark the grid lines
- Ruler (As long as possible, I used long wooden ruler from Home Depot)
- Multi meter
Step 2: Measurement and Grid Lines
The standard ratio of USA flag is 10:19 (Length: Breadth), the aim is to make flag that is 30inches breadth meaning that the length will be 15.8inches (rounded to 16). Cut out 16" x 30" from the polystyrene sheet, make sure you have minimum of 1/2 inch on all edges (this is useful for attaching the wooden frame at the very end.
Mark out 1/4" space from left side of the board to the right and 1.18" from top to the bottom forming a grid. I have attached excel sheet that show the LED layout for visual aid. Ensure that all the grid intersections are numbered left to right and top to bottom (Rows and columns). There should be 39 rows and 60 columns making a total of 2,340 LEDs; spreadsheet also included LED counts.
Step 3: LED Hole Drilling
Using drill press (preferable one with Laser guide) and 3/16" drill bit, drill LED holes at the intersection of the grid drawn out above. Use a 3/16" drill bit will ensure the LED fits snugly into the hole, but it require a bit of effort to place LED in.
The drill press that I used was only able to reach about 4 1/2" around the rectangular polystyrene sheet meaning that it was not possible to get to the inner part of the sheet, fortunately, the polystyrene sheet was flexible enough to be bent around so I was able to use the press to completely drill all the 2,340 holes. Also, I made a mistake while I was measuring out my grid, instead of having 60 columns as I had planned it out on the spreadsheet, I had 59! So in total I only had 2,301 holes to drill; this did not make much of difference in the final product though
Step 4: Current Limiting Resistor
The LEDs were connected in series and then parallel, I used LED wizard to figure out the resistor values that will be required to limit current flowing through the LEDs.
Since the bulk of the LEDs are in set of three rows, the suggested pattern that uses 100 ohms current limiting resistors was adopted (Note that there are 35 columns for the first seven stripes and 60 columns for the remaining 6 stripes all of them having three LEDs in series. The image below only show a representative image and not the entire picture, refer to the spreadsheet for entire representation)
Step 5: LEDs in Drilled Holes & Solder
Ensure that the cathode pins are all facing the same direction; typically, if starting from top to bottom the cathode should be facing South
Cut the cathode pin of the first LED in the series leaving a little above 1/8" then place a solder lead at the very top of the cut pin, similarly, cut one end of the resistor wire a little above 1/8" then place a solder lead at the very top of the cut pin
Join the resistor with the cathode pin of the LED as shown in the image above. There is another picture of the LEDs being laid out as described, notice the resistor conveniently attached to styro-foam.
Once all the series and parallel connections have been completed, there should be 15 cathode pins and 15 anode pins. Connect all anode pins together to form one bus. Each of the remaining 15 cathode pins will be used to control the LEDs using Arduino
Step 6: Connect LED Board to Arduino
On the Arduino Mega 2560, pins 22 through 36 were used to control the LEDs on the flag. The pins 22 through 34 were used to control the 13 stripes while pin 35 was used for the blue LEDs and pin 36 was used to control the white LEDs that represented 50 stars.
Each Arduino header pin was connected to a N-Chanel MOSFET so that current being drawn by the LEDs cannot destroy the Arduino board. Arduino and the LEDs were powered by a 12V 10A power supply
Arduino sketch is attached and it is heavily commented. The sketch uses Software Pulse Width Modulation by bhagman found at at the following URL:
and ideas found from the Bob Powell's sketch at the following URL:
The software PWM library is attached as a zipped file, unzip into Arduino library folder so it can be referenced by the USA flag sketch. The main reason for using the software PWM library is so the LEDs can be operated at various brightness levels and since there are limited PMW pins on an Arduino soft PWM is used so any pin can be pulse width modulated. When the LEDs are operated below their full brightness levels, the current requirements are significantly reduced; for instance at full brightness level, all the 2,301 LEDs on the board consume more than 6A, however at the various brightness levels tested and used, current requirement when all the LEDs are on is well below 600ma!
Step 7: Case Build
A simple wooden box was built around the LED board, then painted black as shown. Yeah, I know the final packaging could have been done a little better, but this is the best I could come up with, the fact is that it worked and is protected from the elements when placed outside for display.