Introduction: 42 RGB LED Pixel Art Painting

Hey,

So for a school assignment called " If this then that" I had to make an interactive //something// using an Arduino Uno starterkit (and whatever else one was willing to buy themselves). Seeing as im doing an Art/Technology study I wanted to make a combination of them both (art & tech). I figured i would make a painting consisting of as many RGB LEDS as i could fit on my Arduino and let the player/artist manually cycle through those RGB LEDS and choose a color. This way they can make their very own "pixel art"!

Step 1: Some Background Info and Theory

Okay so, lets not beat around the bush. If you want to make this project come to life: Its hard. It took me many hours to figure out/learn what to do, and even more to actually accomplish it, but if you really want a box filled with wire that can create very small " paintings" i'll teach you how.

So, first things first. We want as many LEDs/RGB LEDS on our Arduino as possible. The more (RGB)LEDs you connect the more detailled you can make your " painting" (10x10 pixels give you more wiggle room than 2x2 right). I suppose there are more ways to actually get a lot of (RGB) LEDs on your 13 digital pins (things like a shift register) but i used a method called "Charlieplexing". I will link to a instructable that helped me understand this concept (seriously they explain it really well), but i'll also give you the quick version here. Charlieplexing goes as follows:

You put a LED between pin 1 and pin 2, if you set pin 1 to HIGH and 2 to LOW the circle will run smoothly and the LED will turn on. Basics. Well, now you attach another LED, but flipped around. The long end is on the 2 and the short end is on pin1. Now if you turn pin 2 to HIGH and pin 1 to LOW your 2nd LED will turn on and your first will stay off because the flow will be wrong. Now you can attach 2 LEDs on 2 pins. If we get the 3th pin in the mix, you can do this trick between 1 and 2, 1 and 3, and 2 and 3. Thats 6 LEDs. This continues, 5 pins will grant us (2 + 4 + 6 + 8 ) 20 LEDs. Using all 13 digital pins gives us 156 options. Thats 156 LEDS you can individually turn on and off.

(okay so for those of you wondering. Yes when you have a lot its impossible to actually have some on at the same time, but no worries, the arduino can switch between your LEDs so quickly the human eye cannot see the flickering)

( Better and more detailed explaination, with pictures )

Okay so, with a lot of effort when it comes to wiring (i will touch on this later), we can make quite a grid of LEDs, but lets face it. LEDs are terribly boring. How can one make a picture with only 2 colors? I suppose you could, but its way cooler if you have more colors to pick from right? right. So to the RGB LEDs we turn!

RGB LEDs are basically 3 LEDs in 1. They share a common cathode or anode (where the power goes in or out) and the other 3 " legs" are your Red Green and Blue LED. Keeping this in mind, yes we can charlieplex them too! Every RGB LED counts for 3 regular LEDs. That way you can still turn them all on and off individually and create cool colors to choose from! The only downside is that this makes things a lot more difficult as you have to map/plan and wire 3 times as many LEDs as you originally had to.

I went for 42 RGB LEDs on 13 pins. Thats 126 regular LEDs.....quite the number. Let me tell you how i did it.

Step 2: Planning

Yeah this step is pretty easy once you understand the theory behind what youre doing. You basically write out all your LEDs and plan which pin needs to go to which "leg" of which RGB LED so you cover all your options. I attached a picture of my planning, feel free to use that too (i didnt use all options available seeing as i " only" needed 126 connections out of the 156. I structured it this way because it would make construction a tinsy bit more doable).

Its important to get this on paper, you will need it later to code. If you do not write this out, and mess up 1 connection the code will not work for that LED.

Step 3: The Code

Okay, so if you have an idea already on how to wire 2 RGB LEDs like this on 2 pins: Go ahead! Its nice to check the code, but i assure you it works! I tried to do as much of "clean" coding as i possibly could (You could also manage this with switches in switches but thats just a terrible hassle that has you write down all your code x42, it made me realize there was probably a better way).

The goal of the code is the following. You start at LED1. Button 1 lets you move to the next LED but your previous LED stays on. Button2 lets you go back to the previous LED, button 3 lets you change the color. The current selected LED blinks so you can see which LED is "selected".

To accomplish this i worked with arrays. I created a LED class that uses the info you wrote down during the planning stage to see which pin it needs to create a certain color. I put them all in an array and i let the arduino loop through the LEDarray to determine which one is on and through the colorarray to determine which color is selected (the color is determined by the switch that allows for 7 colors to be picked). The blinking is regulated by an if-statement.

The code is attached, feel free to download and use. The comment section is open for questions if there is something you don't understand, but you can basically copy paste!

Step 4: The Hardest Part

So now you have an idea, a working code....just not the actual product. This is by far the most horrible part of this project and i would advise you to not take this lightly. Remember all those different legs that all end in the same pin? well yeah...you have to make your grid of LEDs, then connect every leg to every other leg that needs to go to the same pin, and then conected them to said pin. This is by far the most difficult part and mine didnt come out a 100% perfect either, if youre good at soldering you might have a chance though.

I put in a row of RGB LEDs at a time and connected a copper wire to each leg (i recommend copper wire with casing/wrapping. Mine was too thick and it caused me a LOT of grief). Be careful that no two legs or wires touch eachother! then " simply " connect all wires that need to go to the same pin and then conect them to a resistor and connect that to said pin. Im sure there is a " safer" way to do this, but im sure one would drown in wire while trying and honestly....your breadboard is only so big!

(i added a drawing that might simplify this step. It tells you which leg needs to go to which pin, to follow my code exactly.)

It took me 4 whole days of work, but now each LED (minus 3-4 that i screwed up) can be turned on individually!

then you only have to wire in some buttons and presto! Your own Pixel Art Painting!

This guy also made an example of wiring, its real helpful

Step 5: Gloat. Absolutely Gloat.

If youre a starter (like me) and you managed to make something even akin to this rats nest of wires and it turns on; gloat. You did real good!

If you have any questions/comments just leave them below, i will try to help if i can!