# 5x5 LED Matrix Animations

19,344

111

5

## Introduction: 5x5 LED Matrix Animations

DON'T WORRY ABOUT 5 X 5 X 5 PROJECTS. focused on 25 leds 5 x 5.

25 LED's - I used blue 5mm LED's purchased on eBay 5 resistors - I used 100 ohm, but the exact value will depend on what LED's you use. I will explain how to calculate in the Wiring step.

Arduino - I used a UNO

## Step 1: How to Wires Them Up

To drive our 5x5 LED matrix, we directly drive the LED's using 10 digital I/O pins on the Arduino.The anodes are connected to pins. Some existing designs, such as the one in the Arduino Playground don't bother to use current limiting resistors. This is not a good design practice, and can result in burned out LED's, or worse yet, a burned out Arduino. Each I/O pin on the Arduino can source or sink up to 40mA of current. The LED's which I used have the following electrical characteristics: Forward Voltage = 3.2 ~ 3.4V Max Continuous Forward Current = 20mASo if we want to drive the LED's for maximum brightness, we need to target 20mA of current.To calculate the proper resistor value, we use Ohm's Law: R = (Vcc - Vf) / Ifwhere R = resistor value in ohms Vcc = supply voltage = 5V for the Arduino Duemilanove Vf = LED forward voltage. I used the average, 3.3V If = LED current in amperes = .020APlugging in the values, we get R = (5 - 3.3) / .02 = 85 ohms. The nearest available standard resistor value is 100 ohms. Always round up instead of down, because if you round down, you will exceed the maximum allowable current.Notice that we only use 5 resistors. We don't have to put one at each LED, because we will only be driving one row, a maximum of 5 LED's at a time. I said above that each I/O pin can drive 40mA of continuous current, so why can't we drive the whole LED array at once? It's because another constraint is that the total drive current summed up across all the pins can't exceed 200mA. If we turn on all 25 LED's at once, then 25*20mA = 500mA flow, which is way over spec.So maybe we can turn on 1 row at a time, and scan the rows, like the way a CRT works? If we turn on a whole row of LED's at once, the current is 20mA * 5 = 100mA. This, at first, appears to be OK, because each column (anode) pin is only sourcing 20mA, and we're below the Atmega368P's total 200mA current limit. However, upon more analysis, we can't even drive 5 LED's at once. Why? Because the cathodes of all 5 LED's in a row are connected together into a single I/O pin, and we're not allowed to sink more than 40mA per pin. Therefore, we will write our software so that no more than 2 LED's are turned on at a time, so the row (cathode) pins will sink a maximum of 40mA each. Now, even though we're at the allowable continuous current limit, it's generally not good practice to run a device at its maximum limits. However, since we're going to pulse each LED briefly, and let persistence of vision create the illusion that they're all on at once, it's OK.Note: I tried running mine w/ 5 LED's lit per row for several hours, and it worked fine, but it's always best to design your circuits within specifications, to ensure long term reliability.

## Step 2: Time to Test

see if you are property connect the wires with Arduino to check the code is at TESTMODE by remove the comments (//) on line 13 the Arduino 1.0.5 extension .ino does not show on the line 13 number of the rows every time the enter key press. I am using sublime text 2 since its free and its super useful. here the video for example you will get some idea.

by the way dont worry about the file called frames.h. do this first step we will do frames.h in next step

time to test matrix on 5 x 5 leds

## Step 3: Custom 5 X 5 Bits

I have decided to make own bits by using daftpunkanimationbuilder.html learn how to custom 5 x 5 matrix bits

the easiest way to custom matrix.

If you would like to learn how to custom 8 x 8 matrix bits, really its up to you. it possibly for your next project. its very worth to try it!

## Step 4: Programming Testmode

this is very interesting for me to understand the code how they work "for" function on test mode.

if I reserve the LOW TO HIGH on line 109 and HIGH to LOW ON 115 and it will look like this...

```

while (1) {

for (i=0;i < DIM;i++) { digitalWrite(rows[i],HIGH); for (int j=0;j < DIM;j++) { digitalWrite(cols[j],HIGH); delay(250); digitalWrite(cols[j],LOW); } digitalWrite(rows[i],LOW); } }

```

the while number define is 1 is always true it running for the loop remember the DIM define number is 5 on 15 line starts number at 1 not start at 0 since its not an array number so it count from pattern 1,2,3,4,5. hope it does not confused you. see here video change LOW to HIGH

when the DIM starts number at 1 doing the "for" function with array "rows" number to tell HIGH on 109 line. it continue to next "for" function. and the second function DIM will do counts 1,2,3,4,5 do same thing for array "cols" number delay (250) high and low five times when it finish the next is to tell DIM number at 1 to LOW. and the new number 2 for DIM is set up as HIGH while the number 1 is LOW. 2 is low 3 is high, 3 is low and 4 is high etc, it hard for me to explain to you. I try best as i can.