Introduction: Charlieplexed Row of LED Lights, for the Arduino

Picture of Charlieplexed Row of LED Lights, for the Arduino

 This is my instructable on charlieplexing a LED row/string with the arduino. I noticed that there weren't many instructables on charlieplexing using an arduino, so i made this. I tried to keep the project simple, but that didn't work very well. The soldering is complex, I wouldn't recommend this as a first time soldering project.

Here's some background on charlieplexing:

I took about 80 pictures & not all of them made it into the main steps, but you can find them in step 9: Extra Pictures

If you have any comments, questions &/or suggestions please ask them!


Step 1: Parts List:

Picture of Parts List:

- 12 LED's; I'm using some 3 mm Red LED's
- 4, 270 Ohm resistors; You can use other values as well
- Perfboard/Veroboard; I used a piece 27 holes x 5 holes
- Wire; I used some 26 gauge, solid core wire
- Header pins (optional)
- Arduino

- Soldering Iron
- Hot glue gun (optional)
- Helping hand (optional)

Step 2: Solder the Anodes of the LED's

Picture of Solder the Anodes of the LED's

There's not much to say about the next few steps, but there's a few main points I'll mention.
- The LED's anodes are soldered in groups of 3
- Make sure the 4 groups don't get joined together, but stay separate

The wires that connect the 4 groups are kind of shaped like a L.

Step 3: Bend the Cathodes

Picture of Bend the Cathodes

Main Points:
- You should end up with 4 different rows
- Make sure each of the the 4 rows contain only 3 connections to the cathodes & only one from each group of LED

Step 4: Solder the Cathodes

Picture of Solder the Cathodes

Main Points:
Not much to say here just solder the 4 rows & make sure to avoid any bridges in the wires. You should have 4 rows that have only 3 connections to it, one from each group with one group not attached. I tried to make the schematic as close to the wiring as possible, so that might make what I'm talking about a little easier to understand. It's is the last picture on this step.

Step 5: Install Resistors

Picture of Install Resistors

This is a little confusing. Hope I explained it well enough. There are more pictures of this in step 9.

Resistor end connections:
1) One end connected to row 1. The other to group 4
2) One end connected to row 2. The other to group 3
3) One end connected to row 4. The other to group 2
4) One end connected to row 3. The other to group 1

Step 6: Add the Control Wires

Picture of Add the Control Wires

This is probably one of the easiest steps! All you are doing is soldering wires to the 4 groups.

I used some pieces of wire about 6 in long. They don't have to be different colors but it can be helpful if anything goes wrong & you need to debug the circuit. You don't need some header pins, but if you want some feel free to use them.

Step 7: Coding the Arduino

Picture of Coding the Arduino

Here's some basic steps to program your arduino.

1) Download the source code from below
2) Open the file in the Arduino IDE
3) Press the "Upload to I/O Board" button
4) Once the program is uploaded it will start running

Note:You may need to change a few things in the "const int ledPins[12][2] ={" array if the led's turn on, out of order.

I tried to add a good amount of comments to the code, but if you have any questions, please ask them.

Step 8: Have Fun!!!

Picture of Have Fun!!!
This shouldn't be to hard, but it might be

If you have any comments, questions &/or suggestions please ask them!

Step 9: Extra Pictures

Picture of Extra Pictures

Well, I'm not sure if I when a little overboard with the pictures, But here's the rest of the pictures if you need something clarified. If you have any questions feel free to ask them.

Pictures 1-9: Installing the LED's
Pictures 10-13: Bending the cathodes
Pictures 14-18: soldering the cathodes
Pictures 19-20: Installing the resistors
Pictures 21-23: Installing the control wires


ChathurangaW1 (author)2016-08-19

i done this by using Arduino and 10 LEDs

watch Video :

AnkitS139 (author)2016-07-10

Error solved ty

AnkitS139 (author)2016-07-10

I'm connecting led strips instead of led's. For number 1 strip pin configs are pin1 high and pin2 low and for 2nd strip, pin2 high and pin1 low. These two pins are clashing with each other. Can anyone suggest me the way.

m10us44 (author)2015-04-27

In file included from sketch_apr27a.ino:1:0:

sketch_apr27a.ino:48:21: error: variable 'displays' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

Fout bij compileren.

ChristianM64 (author)m10us442015-11-06

I googled the message and found a fix here:

In front of this one line

byte displays[][12] PROGMEM ={...

add 'const'.

const byte displays[][12] PROGMEM ={...

It compiled and was able to be sent to the Arduino. Now, my LEDs are out of order, but, I'm making progress! =)

ChristianM64 (author)m10us442015-11-06

I'm getting the same message.

furri (author)2013-09-18

pretty good to use pins as input for a "no HIGH/LOW" value.

Vick Jr (author)2010-08-03

Are the resistors there to protect the LEDs? If the arduino is using around 3 volts then can we skip them? I made a cylon eye scanner that works fine with no resistors. I'm using blueish white xmas light LEDs, so they might take higher voltage anyway.

ardor (author)Vick Jr2011-02-06

I know this question is ancient by now but just in case some one else is looking at this tutorial I'll answer it.

The Arduino uses 5V not 3 so you do need the resisters.

Your christmas tree leds either have resistors in them somehow, are a higher voltage or... Shrug, you got luck somehow...

facilitator476 (author)ardor2011-08-09

Are the resistors that important to led's? ive been using mine for simple light-up projects with an arduino uno and havent hade any problems. Either way if it did start smoking i think i would stay it was part of the design.

bakabr (author)facilitator4762012-10-18

the problem with a burnt diode is that is will get closed "XOR" opened circuit, this in charlieplexing would be veeeeerey painful, because you will get some sequences to light o not light completely, and unles you are using high brightness LED (wich are transparent so you can sometimes identify a burnt one just by looking at it and seeinga a black spot where anode and cathode meet) it wil be difficult to find out wich one is the defective LED. And charlieplexing is intended for HIGH quantities of "matrix points" and they end up being a HIGH quantity of LEDs to check in case any of'em fails. So use resistors for good practice.

OCPik4chu (author)facilitator4762012-10-12

Giving too much voltage and/or amperage to any electronic can kill it. You do not always need a resistor though, it depends entirely on what the voltage and amperage rating on the LEDs are, whether they are connected in series or parallel and what voltage your supply is.

sarath12445 (author)2010-07-06

i am not able to download the code... it is downloading as .tmp format and not as .pde

Rich1953 (author)sarath124452012-05-18

Mine did the same thing. Just re-name .tmp to .pde

phenoptix (author)2012-01-26

Found this to be a very useful instructable, although I found the diagram a little hard to follow. I had a crack at a version myself and came up with the following. I've colour coded the pin outs which has helped me with visualising
My plan is to have play with the code to see if I can improve the bounce of the larson, and perhaps port it to an ATTiny rather than monopolising an Arduino!
Great instructable by the way. Having a look at your new ones now!

pglasspoole (author)phenoptix2012-04-02

Your schematic is backward from the instructable. You have pin 1 going to LED1, LED2, LED3 and the instructable has pin 4 going to LED1, LED2, LED3. Pin 2, pin 3 and pin 4 of the Arduino are also flipped (i.e. 1 to 4, 2 to 3, 3 to 2, and 4 to 1).

Additionally, you both use pin 1, 2, 3, 4 in your schematic and then use 0, 1, 2, 3 in the code.

Lastly, neither of these schematic allow the program to work in all three modes.

Am I missing something or was this just a very poor example of charlieplexing. It is complicated enough without getting contradicting info.

phenoptix (author)pglasspoole2012-04-02

The schematic you've commented on and the instructable have different authors, hence the differences. I went away to try to get my head around charlieplexing and that's what I came up with independently and as it helped me understand the concept, so I thought I'd share it. It was my first attempt and I've improved it since. With the new one below. The pins are labelled ABCD in this version...

The instructable is a really good example of charlieplexing and helped me a lot. It's not the only resource I used to understand the concept.

pglasspoole (author)phenoptix2012-04-03

The schematic above is very well done. Congrats!

Robot Lover (author)2010-08-26

How could I do this with 22 LED's?

Terivia (author)Robot Lover2011-09-02

you would expand the circuit using charliplexing.
(a good explanation is here

to figure out how many pins you need, well the relationship for pins to leds is

y = x^2 - x
with y being leds, and pins being x.

diy_bloke (author)Terivia2011-12-17

Got me back to my highschool days, several decades ago. For those having trouble calculating that:
{1+root(1+4y)}/2 or
(and then take the positive number)

so for 22 LED's this would be 5.7 lines (=6) -> 22 is an ineffecient number of LED's with regard to the number of datalines

3 lines wld service 6 LED's
4 lines wld service 12 LED's
5 lines wld service 20 LED's
6 lines wld service 30 LED's

noik (author)2010-09-07

open it with notepad and copy it to your arduino program, should work

idiotjohn (author)2010-08-08

also on a different point, is it possible to change the pins used? I see that there is a place to define them, but even if i change them there, it does not change it.

idiotjohn (author)2010-08-08

I made it and got it all working without any modification of your code. I went through labeling each LED, using the turnon() function. When I ran turnon(12); it turned on the LED that I had previously labelled as 4. I figured my soldering or something must be wrong... BUT, when I ran the sequence, it ran correctly, all I had to do was place LED 12 in front of LED 1 and then it works. I am very very confused. John

Vick Jr (author)2010-08-03

I wired everything together, all the leds can turn on, and the cylon scanner works, but when certain leds turn on, other random ones will glow dimly. Is this because I left out the resistors or does it mean there's a short somewhere? This is my first charlieplexing project and although it's not perfect, I'm still glad it partially works. thanks!

tonysofla (author)2010-06-23

It's easy to include some type of PWM dimming as Charlieplexing is already a type of duty mode. If counter is higher that fade value, just skip that LED this time.

I have 8bit level PWM here:

noik (author)2010-02-16

 Yes, I managed to make it work.! Thank's al lot, for this great instructable, :)

noik (author)2010-02-16

 Code doesn't work with my arduino, it gives a error. 
Nice instructable!

nolte919 (author)2009-10-26

I know it would be a pain to change at this point but your schematic is a bit confusing.  I think you call it "Circuit Diagram.png".  It appears the red wire coming from pin 3 through the resistor is going to BOTH the anode and cathode of the three pins it's attached to.  After a little thought it's clear you meant it to go only to the cathode but this might be more confusing to somebody else.

Great instructable.

computergeek (author)nolte9192009-10-26

 Thanks for pointing that out. I just changed that. Fortunately I still had the Eagle CAD file.

WyoJustin (author)2009-10-21

Sweet!  Clever design. Great instructions.  Great photos.

Nice work.

richms (author)2009-10-21

An easier way is to put half the resistance into each of the wires, and then you can swap the polarity of 2 neighbouring LEDs to get less of the looping around connections happening.

beardy (author)2009-10-21

 Brilliant!  Thank you.

Seems to be a relatively 'simple' how-to.  I've been wanting to do this for a while but have been a bit bamboozled when it comes to actually wiring it.

DarkStarPDX (author)2009-10-07

Dude, I'm thinking that we need to replace those LEDs with some 12 volt relays and wire up some real lights onto the back of the car! :-)

computergeek (author)DarkStarPDX2009-10-07

 That would definitely be something! You would need a diode for each relay. The reason charlieplexing works, is LED's are diodes so current only flows one way through them. 

Bongmaster (author)2009-10-07

looks fun and complex O_o

computergeek (author)Bongmaster2009-10-07

 It is really fun! It Definitely isn't the easiest thing I've built, But I think it was worth the effort.

About This Instructable




More by computergeek:DIY Apple Remote (Slideshow for the instructable)DIY Apple Remote Shield for the ArduinoSimple 2-way motor control for the arduino
Add instructable to: