8*16 dot matix display using atmega8 and 74hc595
Proteus Design:
CODE:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
const char dotmatrix[27][8] PROGMEM=
{
{
0b11000110,
0b11000110,
0b11111110,
0b11111110, //A
0b10000010,
0b10000010,
0b01111100,
0b00111000,
},
{
0b11111110,
0b10000001,
0b10000001,
0b10000110,
0b11111110, //B
0b10000001,
0b10000001,
0b11111110,
},
{
0b01111110,
0b10000001,
0b10000000,
0b10000000, //C
0b10000000,
0b10000011,
0b10000001,
0b01111110,
},
{
0b11111000,
0b11000100,
0b11000110,
0b11000110,
0b11000110, //D
0b11000110,
0b11000100,
0b11111000,
},
{
0b11111110,
0b11000000,
0b11000000,
0b11111000, //E
0b11111000,
0b11000000,
0b11000000,
0b11111110,
},
{
0b10000000,
0b10000000,
0b10000000,
0b10000000,
0b11111000, //F
0b10000000,
0b10000000,
0b11111111,
},
{
0b01111110,
0b10000010,
0b10001110,
0b10000000, //G
0b10000000,
0b10000000,
0b10000001,
0b01111110,
},
{
0b10000001,
0b10000001,
0b10000001,
0b10000001, //H
0b11111111,
0b10000001,
0b10000001,
0b10000001,
},
{
0b01111100,
0b00010000,
0b00010000,
0b00010000, //I
0b00010000,
0b00010000,
0b00010000,
0b01111100,
},
{
0b00001100,
0b00010010,
0b00010010,
0b00010000, //J
0b00010000,
0b00010000,
0b00010000,
0b01111110,
},
{
0b10001100,
0b10010000,
0b10100000,
0b11000000, //K
0b11000000,
0b10100000,
0b10010000,
0b10001100,
},
{
0b11111110,
0b10000000,
0b10000000, //L
0b10000000,
0b10000000,
0b10000000,
0b10000000,
0b10000000,
},
{
0b01000010,
0b01000010,
0b01000010,
0b01000010,
0b01000010, //M
0b01011010,
0b01100110,
0b01000010,
},
{
0b10000001,
0b10000011,
0b10000101,
0b10001001,
0b10010001, //N
0b10100001,
0b11000001,
0b10000001,
},
{
0b00111100,
0b01000010,
0b10000001,
0b10000001, //O
0b10000001,
0b10000001,
0b01000010,
0b00111100,
},
{
0b10000000,
0b10000000,
0b10000000,
0b10000000, //P
0b11111110,
0b10000001,
0b10000001,
0b11111110,
},
{
0b00000011,
0b10000100,
0b01111110,
0b10001001, //Q
0b10010001,
0b10000001,
0b10000001,
0b01111110,
},
{
0b10000110,
0b10001000,
0b10010000,
0b10100000,
0b11111110, //R
0b10000001,
0b10000001,
0b11111110,
},
{
0b01111100,
0b10000010,
0b00000010,
0b01111100, //S
0b10000000,
0b10000000,
0b01000010,
0b00111100,
},
{
0b00010000,
0b00010000,
0b00010000,
0b00010000, //T
0b00010000,
0b00010000,
0b00010000,
0b11111110,
},
{
0b00111100,
0b01000010,
0b10000001,
0b10000001, //U
0b10000001,
0b10000001,
0b10000001,
0b10000001,
},
{
0b00011000,
0b00100100,
0b01000010,
0b01000010, //v
0b10000001,
0b10000001,
0b10000001,
0b10000001,
},
{
0b11000011,
0b11000011,
0b10100101,
0b10011001, //W
0b10000001,
0b10000001,
0b10000001,
0b10000001,
},
{
0b10000001,
0b10000001,
0b01000010,
0b00100100, //X
0b00011000,
0b00100100,
0b01000010,
0b10000001,
},
{
0b00011000,
0b00011000,
0b00011000,
0b00011000, //Y
0b00100100,
0b01000010,
0b10000001,
0b10000001,
},
{
0b11111111,
0b11000000,
0b01100000,
0b00110000, //Z
0b00011000,
0b00001100,
0b00000110,
0b11111111,
},
{
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
},
};
int main(void){
DDRD=0xFF;
DDRC=0xFF;
PORTD=0xFF;
PORTC=0x00;
int k,j,l,q,i,s,t=1,sp=5,in,dec,array[]={18,0,4,4,3,26,26,26};
char A;
unsigned long aaa,x;
while(1){t=1;
for(s=0;s<=4;s++){
for(q=7;q>=0;q--){
if(t){q=32;t=0;}
for(j=0;j<sp;j++){ //defines speed
for(k=0;k<=7;k++){
aaa=0x00;
A=pgm_read_byte(&(dotmatrix[array[s]][k]));
aaa=aaa|A;
aaa=aaa<<8;
A=pgm_read_byte(&(dotmatrix[array[s+1]][k]));
aaa=aaa|A;
aaa=aaa<<8;
A=pgm_read_byte(&(dotmatrix[array[s+2]][k]));
aaa=aaa|A;
aaa=aaa<<8;
A=pgm_read_byte(&(dotmatrix[array[s+3]][k]));
aaa=aaa|A;
aaa=(aaa>>q);
for(i=31;i>=0;i--){
PORTD=0b11111111;
PORTC=0b00000000;
x=aaa&(1<<i);
if(x)
PORTC=0b00000011;
//_delay_ms(1);}
else
PORTC=0b00000010;
//_delay_ms(1);}
}
PORTC=0b00000100;
PORTD=0b11111111^(1<<(k));
if(t==1)
_delay_ms(0.1);
else
_delay_ms(0.2);
}
}
}
}
}
return 0;
}
No comments:
Post a Comment