You are on page 1of 9

PROJECT NAME:ALPHABET DISPLAY BY 8X8 LED MATRIX WITH Arduino .

DESCRIPTION: 8X8 LED matrix displays are often packaged as matrixes of LEDs
arranged in rows of common cathodes and columns of common anodes, or the
reverse. The 16 pins of the matrix are hooked up to 16 pins of the Arduino. Four
of the analog pins are used as digital inputs A0 through A3. You can add and
remove patterns as you like in this matrix.

COMPONENT REQUIRED:

SERIAL NO. COMPONENT NAME QUANTITY

1. Arduino/Roboduino board 1
2. Robospecies 8x8LED matrix 1
3. USB cable 1
4. F2F wires
5. Battery jack 1
6. DC Battery 9V 1

CIRCUIT: LEDs in the same column have the anodes on a common line, running
top to bottom. Similarly for LEDs in a single row have cathodes on a common line,
running left to right.
These can be very useful displays. To control a matrix, you connect both its
rows and columns to your microcontroller. The columns are connected to the
LEDs anodes (see Figure ), so a column needs to be high for any of the LEDs in
to turn on. The row are connected to the LEDs cathode, so the row needs to be
low for an individual LED to turn on. If the row and the column are both high
or both low, no voltage flows through the LED and it doesnt turn on.

To control an individual LED, you set its column high and its row low. To
control multiple LEDs in a row, you set the rows high, then take the column
high, then set the lows row or high as appropriate; a low row will turn the
corresponding LED on, and a high row will turn it off.
Although there are pre-made LED matrices, you can also make your own
matrix from 64 LEDs, using the schematic as shown above.

CODE:(display ROBOSPECIES or change to display custom word with #define )

#include <FrequencyTimer2.h>
#define d1 { \
{0,0,0,0,0,0,0,0},\
{0,0,0,1,1,1,0,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,1,1,0,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0} \
}
#define d2 { \
{0,0,0,0,0,0,0,0},\
{0,0,0,1,1,1,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,0,0,1,0},\
{0,0,0,1,1,1,1,0} \
}
#define d3 {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,0,0},\
{0,0,0,0,1,0,0,0},\
{0,0,0,0,1,0,0,0},\
{0,0,0,0,1,0,0,0},\
{0,0,0,0,1,0,0,0},\
{0,0,0,1,1,1,0,0} \
}
#define d0 { \
{0,0,0,0,0,0,0,0},\
{0,0,0,0,1,1,1,0},\
{0,0,0,1,0,0,0,0},\
{0,0,0,1,0,0,0,0},\
{0,0,0,0,1,1,1,0},\
{0,0,0,1,0,0,0,0},\
{0,0,0,1,0,0,0,0},\
{0,0,0,0,1,1,1,0} \
}
#define d11 { \
{0,0,0,0,0,0,0,0},\
{0,0,0,0,1,1,1,0},\
{0,0,0,1,0,0,0,0},\
{0,0,0,1,0,0,0,0},\
{0,0,0,0,1,1,0,0},\
{0,0,0,0,0,0,1,0},\
{0,0,0,0,0,0,1,0},\
{0,0,0,1,1,1,0,0} \
}

byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to


make array start at pos 1)
int pins[17]= {-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17};

int cols[8] = {pins[8], pins[7], pins[6], pins[5], pins[13], pins[14],


pins[15], pins[16]};//(C1-C4 PIN-9 to6),pin 14-17(c5-c8)

int rows[8] = {pins[1], pins[2], pins[3], pins[4], pins[12], pins[11],


pins[10], pins[9]};//pin 10-13(R1-R4),pin 5-2(R5-R8)

const int numPatterns = 11;


byte patterns[numPatterns][8][8] = {
d1,d2,d3,d4,d5,d6,d7,d8,d9,d0,d11
};

int pattern = 0;

void setup() {
Serial.begin(9600);
// sets the pins as output
for (int ii = 1; ii <= 16; ii++) {
pinMode(pins[ii], OUTPUT);
}

// set up cols and rows


for (int ii = 1; ii <= 8; ii++) {
digitalWrite(cols[ii - 1], LOW);
}

for (int ii = 1; ii <= 8; ii++) {


digitalWrite(rows[ii - 1], LOW);
}

clearLeds();

// Turn off toggling of pin 11


FrequencyTimer2::disable();
// Set refresh rate (interrupt timeout period)
FrequencyTimer2::setPeriod(2000);
// Set interrupt routine to be called
FrequencyTimer2::setOnOverflow(display);

setPattern(pattern);
Serial.println(availableMemory()); // 670 bytes for charNum = 15
}

void loop() {
pattern = ++pattern % numPatterns;
slidePattern(pattern, 320);
}

void clearLeds() {
// Clear display array
for (int ii = 0; ii < 8; ii++) {
for (int jj = 0; jj < 8; jj++) {
leds[ii][jj] = 0;
}
}
}

void setPattern(int pattern) {


for (int ii = 0; ii < 8; ii++) {
for (int jj = 0; jj < 8; jj++) {
leds[ii][jj] = patterns[pattern][ii][jj];
}
}
}

void slidePattern(int pattern, int del) {


for (int ll = 0; ll < 8; ll++) {
for (int ii = 0; ii < 7; ii++) {
for (int jj = 0; jj < 8; jj++) {
leds[jj][ii] = leds[jj][ii+1l];
}
}
for (int jj = 0; jj < 8; jj++) {
leds[jj][7] = patterns[pattern][jj][0 + ll];
}
delay(del);
}
}
// Interrupt routine
void display() {
digitalWrite(cols[col], LOW); // Turn whole previous column off
col++;
if (col == 8) {
col = 0;
}
for (int row = 0; row < 8; row++) {
if (leds[col][7 - row] == 1) {
digitalWrite(rows[row], LOW); // Turn on this led
}
else {
digitalWrite(rows[row], HIGH); // Turn off this led
}
}
digitalWrite(cols[col], HIGH); // Turn whole column on at once (for
equal lighting times)
}
// this function will return the number of bytes currently free in RAM
int availableMemory() {
int size = 1024;
byte *buf;
while ((buf = (byte *) malloc(--size)) == NULL);
free(buf);
return size;
}

You might also like