Simple Arduino 5x2 LED Matrix

9.2K164

Intro: Simple Arduino 5x2 LED Matrix

This is my First Arduino project so bear with me. 
This a simple LED Matrix that is run by an Arduino Uno 3.
You will need these parts:

-10 LEDs
-Arduino Board
-Breadbord
-Jumper Wires
-And some solid core wire


STEP 1: LED Placement

Place the LEDs across the middle of the breadboard one LED row on one side and one LED row on the other.
Place the LEDs so that each pin is in a different row on the breadboard. 

STEP 2: Grounding the LEDs

Then take small bits of the solid core wire and pin them down one the row in which each cathode is in. Take the other end and put it in one of the power slots. When you are done connecting all of the LEDs cathodes to the power slot connect the the two power slots with one long peice of wire.let yet another piece of wire connect to your Arduino.

STEP 3: The Positive Leads.

Instead of just putting a jumper cable into the same row as the LED's anodes, I lead some wire out away from the LEDs on the breadboard so that I could attach the jumper wires to them. Away from the LEDs so that it would look better. This improved my project a lot I think.

STEP 4: Coding

I was lazy when coding and just modified the "Blink" sketch to fit my matrix.
Here is the code

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;
int led9 = 10;
int led10 = 11;
int brightness = 0;  
int fadeAmount = 5;


// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH);   // turn the LED on (HIGH is the voltage level)
delay(75);               // wait for a second
digitalWrite(led1, LOW);
delay(75);// turn the LED off by making the voltage LOWdelay(100);
digitalWrite(led10, HIGH);
delay (75);
digitalWrite(led10, LOW);
delay(75);
digitalWrite(led1, HIGH);
delay (75);
digitalWrite(led1, LOW);
delay(75);
digitalWrite(led2, HIGH);
delay (75);
digitalWrite(led2, LOW);
delay(75);
digitalWrite(led3, HIGH);
delay (75);
digitalWrite(led3, LOW);
delay(75);
digitalWrite(led6, HIGH);
delay (75);
digitalWrite(led6, LOW);
delay(75);
digitalWrite(led9, HIGH);
delay (75);
digitalWrite(led9, LOW);
delay(75);
digitalWrite(led8, HIGH);
delay (75);
digitalWrite(led8, LOW);
delay(75);
digitalWrite(led10, HIGH);
delay (75);
digitalWrite(led10, LOW);
delay(75);
digitalWrite(led7, HIGH);
delay (75);
digitalWrite(led7, LOW);
delay(75);
digitalWrite(led1, HIGH);
delay (75);
digitalWrite(led1, LOW);
delay(75);
digitalWrite(led5, HIGH);
delay (75);
digitalWrite(led5, LOW);
delay(75);
digitalWrite(led2, HIGH);
delay (75);
digitalWrite(led2, LOW);
delay(75);
digitalWrite(led9, HIGH);
delay (75);
digitalWrite(led9, LOW);
delay(75);
digitalWrite(led7, HIGH);
delay (75);
digitalWrite(led7, LOW);
delay(75);
digitalWrite(led6, HIGH);
delay (75);
digitalWrite(led6, LOW);
delay(75);
digitalWrite(led3, HIGH);
delay (75);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led8, HIGH);
delay (75);
digitalWrite(led8, LOW);
delay(75);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
digitalWrite(led9, HIGH);
digitalWrite(led10, HIGH);
delay(150);

analogWrite(led1, brightness);
analogWrite(led2, brightness);
analogWrite(led3, brightness);
analogWrite(led4, brightness);
analogWrite(led5, brightness);
analogWrite(led6, brightness);
analogWrite(led7, brightness);
analogWrite(led8, brightness);
analogWrite(led9, brightness);
analogWrite(led10, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }    
  // wait for 30 milliseconds to see the dimming effect   
  delay(30);                           
}

STEP 5: Hook Up the Arduino Board and Have Fun!

Upload the code to your Arduino, plug up the matrix and enjoy the show!
You can modify the code all you wish to get personal effects.

4 Comments

Thanks man. Was a good tutorial. Had a good time doing it.
You should use some current limiting resistors there. You're lucky in that white LEDs have a high Vf (forward voltage drop) and thus don't need a large resistor to keep the current low.

http://en.wikipedia.org/wiki/LED_circuit

http://led.linear1.org/led.wiz

dont know why they are showing up blue... Odd. I was using my old iphone 3g for pictures so that explains the low quality.
I am actually using green ones and I have done some simple led things before without burning out any leds before. Although you are quite right. Just didn't have any layin around..