Re: 8x8 led matrix
// Amir Rasheed
// 0345-5917219
//******************************************************************************
#include <reg51.h>
#include "table.h" //defined lookup table for MMD LED patern
#define set 1
#define reset 0
unsigned char bdata temp; // bit addressable memory location variable
sfr port2 = 0xA0; // port2 is used for row scanning attached with 74LS145
sbit MSB=temp^7; // MSB bit of temp variable to make data serialized
sbit clk = P3^2; // Clock Pin 3/12 ----> MBI5026/8051 P3^2 PIN_12
sbit sdata = P3^3; // port pin for data Serialization P3^3 PIN_13
unsigned char scan[8]={0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7}; //Row selection
unsigned char ser_copy[]={"AMIR"}; // store incomming 5 characters
void main()
{
unsigned char row,col,count,i;
while (1)
{
for (col=0; col<8; col++) // loop for selecting columns
{
for (i=0; i<4; i++) // loop for INSERTING WORDS
{
row = ser_copy;
row = row-0x0D; //staring hex code of lookup table is 0x0d
{
temp = matrix_arr[row][col];
for (count=0; count<8; count++) //SERIALIZATION
{
clk=0; // low to high transition
sdata = MSB; // (serial data to MMd) sdata = P3^1
clk = 1; // (for MMD) clk = P3^2
temp = temp << 1; // bit addressable memory location
}
}
}
port2 = scan[col]; // connected to 4 to 10 decoder/driver
delay_ms(2); // For low or high intensity of LEDs
port2 = 0xff;
}
}
}
---------- Post added at 15:28 ---------- Previous post was at 15:26 ----------
The code i have given to you is not based on INTERRUPTS ... its just to provide you an idea of coding it but for better control and brightness you must use interrupts.
Make a lookup table for your desired font.
Regards
Amir Rashid
Engr. Electronics
NADRA HQs, Islamabad