Lâu rồi Chip chưa viết bài nào mới, thời gian này cũng bận lang thang đi kiếm việc....Nên chưa có sản phẩm mới nào ra, bữa trước có bạn Thắng Bùi gửi chip code led cube 888 mà mong muốn chip giúp bạn ấy đăng lên chia sẻ, hi vọng các bạn cùng trao đổi phát triển nhé..Chip đã compile 1 chút, Dùng phần mềm codevision AVR nhé các bạn?
#include <mega32.h>
#include <delay.h>
#define DATA PORTC.0
#define chot PORTC.1
#define xung PORTC.2
#define mat PORTA
#define L1 PORTA.0
#define L2 PORTA.1
#define L3 PORTA.2
#define L4 PORTA.3
#define L5 PORTA.4
#define L6 PORTA.5
#define L7 PORTA.6
#define L8 PORTA.7
unsigned char temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8;
unsigned int i,j;//k,c;
void hienthi(unsigned char x)
{
unsigned char i,temp;
for(i=0;i<8;i++)
{
temp=x;
temp=temp&0x80;//lay ra bit dau tien (bit 7)
if(temp==0x80)//so sanh bit
DATA=1; //bang 1 thi xuat vao chip =1
else
DATA=0; //nguoc lai bang 0
x*=2; //dich bit lay bit trong so thap
xung=0; //tao xung tren chan 11
xung=1; //1 xung dua vào 1 bít
}
}
void xuat()
{
hienthi(temp1);
hienthi(temp2);
hienthi(temp3);
hienthi(temp4);
hienthi(temp5);
hienthi(temp6);
hienthi(temp7);
hienthi(temp8);
chot=0; //xuat du lieu ra output
chot=1;
}
void danglen(unsigned char ms,unsigned int m)
{
for(i=0;i<m;i++)
{
temp1=0xff;temp2=0xff;temp3=0xff;temp4=0xff;temp5=0xff;temp6=0xff;temp7=0xff;temp8=0xff;xuat();
L1=1;delay_ms(ms);L1=0;
L2=1;delay_ms(ms);L2=0;
L3=1;delay_ms(ms);L3=0;
L4=1;delay_ms(ms);L4=0;
L5=1;delay_ms(ms);L5=0;
L6=1;delay_ms(ms);L6=0;
L7=1;delay_ms(ms);L7=0;
L8=1;delay_ms(ms);L8=0;
L7=1;delay_ms(ms);L7=0;
L6=1;delay_ms(ms);L6=0;
L5=1;delay_ms(ms);L5=0;
L4=1;delay_ms(ms);L4=0;
L3=1;delay_ms(ms);L3=0;
L2=1;delay_ms(ms);L2=0;
}
}
////////////////////////////////////////////////////
void pittong2(unsigned char ms,unsigned int m)
{
for(i=0;i<m;i++)
{
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01,temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();mat=0xff;delay_ms(ms);
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();delay_ms(ms);
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();delay_ms(ms);
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();delay_ms(ms);
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();delay_ms(ms);
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();delay_ms(ms);
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();delay_ms(ms);
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();delay_ms(ms);
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();delay_ms(ms);
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();delay_ms(ms);
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();delay_ms(ms);
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();delay_ms(ms);
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();delay_ms(ms);
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();delay_ms(ms);mat=0x00;
}}
////////////////////////////////////////////////////
void pittong(unsigned char ms,unsigned int m)
{
for(i=0;i<m;i++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0xff;xuat();mat=0xff;delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0xff;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0xff;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0xff;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0xff,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0xff;temp4=0x00,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0xff;temp3=0x00;temp4=0x00,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0xff;temp2=0x00;temp3=0x00;temp4=0x00,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0xff;temp3=0x00;temp4=0x00,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0xff;temp4=0x00,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0xff,temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0xff;temp6=0x00;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0xff;temp7=0x00;temp8=0x00;xuat();delay_ms(ms);
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0xff;temp8=0x00;xuat();delay_ms(ms);mat=0x00;
}
}
void khung1(unsigned char ms,unsigned int m)
{
PORTA=0;
for(i=0;i<m;i++)
{
for(j=0;j<(ms+4);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x01;xuat();L1=1;delay_ms(1);L1=0;
}
for(j=0;j<(ms+3);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x03;temp8=0x03;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x03;temp8=0x03;xuat();L2=1;delay_ms(1);L2=0;
}
for(j=0;j<(ms+2);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x07;temp7=0x05;temp8=0x07;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x05;temp7=0x00;temp8=0x05;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x07;temp7=0x05;temp8=0x07;xuat();L3=1;delay_ms(1);L3=0;
}
for(j=0;j<(ms+2);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x0f;temp6=0x09;temp7=0x09;temp8=0x0f;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x09;temp6=0x00;temp7=0x00;temp8=0x09;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x09;temp6=0x00;temp7=0x00;temp8=0x09;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x0f;temp6=0x09;temp7=0x09;temp8=0x0f;xuat();L4=1;delay_ms(1);L4=0;
}
for(j=0;j<(ms+1);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x1f;temp5=0x11;temp6=0x11;temp7=0x11;temp8=0x1f;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x11;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x11;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x11;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x11;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x11;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x11;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x1f;temp5=0x11;temp6=0x11;temp7=0x11;temp8=0x1f;xuat();L5=1;delay_ms(1);L5=0;
}
for(j=0;j<(ms+1);j++)
{
temp1=0x00;temp2=0x00;temp3=0x3f;temp4=0x21;temp5=0x21;temp6=0x21;temp7=0x21;temp8=0x3f;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x21;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x21;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x21;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x21;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x00;temp3=0x21;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x21;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x00;temp2=0x00;temp3=0x21;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x21;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x00;temp2=0x00;temp3=0x3f;temp4=0x21;temp5=0x21;temp6=0x21;temp7=0x21;temp8=0x3f;xuat();L6=1;delay_ms(1);L6=0;
}
for(j=0;j<(ms);j++)
{
temp1=0x00;temp2=0x7f;temp3=0x41;temp4=0x41;temp5=0x41;temp6=0x41;temp7=0x41;temp8=0x7f;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x41;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x41;xuat();L2=1;delay_ms(8);L2=0;
temp1=0x00;temp2=0x41;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x41;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x41;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x41;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x00;temp2=0x41;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x41;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x00;temp2=0x41;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x41;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x00;temp2=0x7f;temp3=0x41;temp4=0x41;temp5=0x41;temp6=0x41;temp7=0x41;temp8=0x7f;xuat();L7=1;delay_ms(1);L7=0;
}
for(j=0;j<(ms);j++)
{
temp1=0xff;temp2=0x81;temp3=0x81;temp4=0x81;temp5=0x81;temp6=0x81;temp7=0x81;temp8=0xff;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x81;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x81;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x81;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x81;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x81;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x81;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x81;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x81;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x81;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x81;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x81;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x81;xuat();L7=1;delay_ms(1);L7=0;
temp1=0xff;temp2=0x81;temp3=0x81;temp4=0x81;temp5=0x81;temp6=0x81;temp7=0x81;temp8=0xff;xuat();L8=1;delay_ms(1);L8=0;
}
for(j=0;j<(ms);j++)
{
temp1=0x00;temp2=0xfe;temp3=0x82;temp4=0x82;temp5=0x82;temp6=0x82;temp7=0x82;temp8=0xfe;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x82;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x82;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x82;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x82;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x82;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x82;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x00;temp2=0x82;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x82;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x00;temp2=0x82;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x82;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x00;temp2=0xfe;temp3=0x82;temp4=0x82;temp5=0x82;temp6=0x82;temp7=0x82;temp8=0xfe;xuat();L7=1;delay_ms(1);L7=0;
}
for(j=0;j<(ms+1);j++)
{
temp1=0x00;temp2=0x00;temp3=0xfc;temp4=0x84;temp5=0x84;temp6=0x84;temp7=0x84;temp8=0xfc;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x84;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x84;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x84;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x84;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x00;temp3=0x84;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x84;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x00;temp2=0x00;temp3=0x84;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x84;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x00;temp2=0x00;temp3=0xfc;temp4=0x84;temp5=0x84;temp6=0x84;temp7=0x84;temp8=0xfc;xuat();L6=1;delay_ms(1);L6=0;
}
for(j=0;j<(ms+1);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0xf8;temp5=0x88;temp6=0x88;temp7=0x88;temp8=0xf8;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x88;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x88;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x88;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x88;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x88;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x88;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0xf8;temp5=0x88;temp6=0x88;temp7=0x88;temp8=0xf8;xuat();L5=1;delay_ms(1);L5=0;
}
for(j=0;j<(ms+2);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0xf0;temp6=0x90;temp7=0x90;temp8=0xf0;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x90;temp6=0x00;temp7=0x00;temp8=0x90;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x90;temp6=0x00;temp7=0x00;temp8=0x90;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0xf0;temp6=0x90;temp7=0x90;temp8=0xf0;xuat();L4=1;delay_ms(1);L4=0;
}
for(j=0;j<(ms+2);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0xe0;temp7=0xa0;temp8=0xe0;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0xa0;temp7=0x00;temp8=0xa0;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0xe0;temp7=0xa0;temp8=0xe0;xuat();L3=1;delay_ms(1);L3=0;
}
for(j=0;j<(ms+3);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0xc0;temp8=0xc0;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0xc0;temp8=0xc0;xuat();L2=1;delay_ms(1);L2=0;
}
for(j=0;j<(ms+4);j++)
{
temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x80;xuat();L1=1;delay_ms(1);L1=0;
}
}
}
void luonsong(unsigned char ms,unsigned int m)
{
for(i=0;i<m;i++)
{
//FAMER 1
for(j=0;j<(ms+1);j++)
{
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L1=1;delay(1);L1=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L3=1;delay(1);L3=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x41;temp2=0x41;temp3=0x41;temp4=0x41;temp5=0x41;temp6=0x41;temp7=0x41;temp8=0x41;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x22;temp2=0x22;temp3=0x22;temp4=0x22;temp5=0x22;temp6=0x22;temp7=0x22;temp8=0x22;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x14;temp2=0x14;temp3=0x14;temp4=0x14;temp5=0x14;temp6=0x14;temp7=0x14;temp8=0x14;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 2
for(j=0;j<(ms+1);j++)
{
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L1=1;delay(1);L1=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L2=1;delay(1);L2=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L3=1;delay(1);L3=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x82;temp2=0x82;temp3=0x82;temp4=0x82;temp5=0x82;temp6=0x82;temp7=0x82;temp8=0x82;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x44;temp2=0x44;temp3=0x44;temp4=0x44;temp5=0x44;temp6=0x44;temp7=0x44;temp8=0x44;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x28;temp2=0x28;temp3=0x28;temp4=0x28;temp5=0x28;temp6=0x28;temp7=0x28;temp8=0x28;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 3
for(j=0;j<(ms+1);j++)
{
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L1=1;delay(1);L1=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L2=1;delay(1);L2=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x88;temp2=0x88;temp3=0x88;temp4=0x88;temp5=0x88;temp6=0x88;temp7=0x88;temp8=0x88;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x50;temp2=0x50;temp3=0x50;temp4=0x50;temp5=0x50;temp6=0x50;temp7=0x50;temp8=0x50;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 4
for(j=0;j<ms;j++)
{
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L1=1;delay(1);L1=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L6=1;delay_ms(1);L6=0;
temp1=0xa0;temp2=0xa0;temp3=0xa0;temp4=0xa0;temp5=0xa0;temp6=0xa0;temp7=0xa0;temp8=0xa0;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 5
for(j=0;j<ms;j++)
{
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 6
for(j=0;j<ms;j++)
{
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x05;temp2=0x05;temp3=0x05;temp4=0x05;temp5=0x05;temp6=0x05;temp7=0x05;temp8=0x05;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L7=1;delay_ms(1);L7=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L8=1;delay(1);L8=0;
}
//FAMER 7
for(j=0;j<(ms+1);j++)
{
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x0a;temp2=0x0a;temp3=0x0a;temp4=0x0a;temp5=0x0a;temp6=0x0a;temp7=0x0a;temp8=0x0a;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x11;temp2=0x11;temp3=0x11;temp4=0x11;temp5=0x11;temp6=0x11;temp7=0x11;temp8=0x11;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L6=1;delay_ms(1);L6=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L7=1;delay(1);L7=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L8=1;delay(1);L8=0;
}
//FAMER 8
for(j=0;j<(ms+1);j++)
{
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x14;temp2=0x14;temp3=0x14;temp4=0x14;temp5=0x14;temp6=0x14;temp7=0x14;temp8=0x14;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x22;temp2=0x22;temp3=0x22;temp4=0x22;temp5=0x22;temp6=0x22;temp7=0x22;temp8=0x22;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x48;temp2=0x48;temp3=0x48;temp4=0x48;temp5=0x48;temp6=0x48;temp7=0x48;temp8=0x48;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L5=1;delay_ms(1);L5=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L6=1;delay(1);L6=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L7=1;delay(1);L7=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L8=1;delay(1);L8=0;
}
//FAMER 8
for(j=0;j<(ms+1);j++)
{
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x28;temp2=0x28;temp3=0x28;temp4=0x28;temp5=0x28;temp6=0x28;temp7=0x28;temp8=0x28;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x44;temp2=0x44;temp3=0x44;temp4=0x44;temp5=0x44;temp6=0x44;temp7=0x44;temp8=0x44;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x82;temp2=0x82;temp3=0x82;temp4=0x82;temp5=0x82;temp6=0x82;temp7=0x82;temp8=0x82;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L5=1;delay_ms(1);L5=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L6=1;delay(1);L6=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L7=1;delay(1);L7=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L8=1;delay(1);L8=0;
}
//FAMER 9
for(j=0;j<(ms+1);j++)
{
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x50;temp2=0x50;temp3=0x50;temp4=0x50;temp5=0x50;temp6=0x50;temp7=0x50;temp8=0x50;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x88;temp2=0x88;temp3=0x88;temp4=0x88;temp5=0x88;temp6=0x88;temp7=0x88;temp8=0x88;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L6=1;delay_ms(1);L6=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L7=1;delay(1);L7=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L8=1;delay(1);L8=0;
}
//FAMER 10
for(j=0;j<ms;j++)
{
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L1=1;delay_ms(1);L1=0;
temp1=0xa0;temp2=0xa0;temp3=0xa0;temp4=0xa0;temp5=0xa0;temp6=0xa0;temp7=0xa0;temp8=0xa0;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L7=1;delay_ms(1);L7=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L8=1;delay(1);L8=0;
}
//FAMER 11
for(j=0;j<ms;j++)
{
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L1=1;delay_ms(1);L1=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x01;temp2=0x01;temp3=0x01;temp4=0x01;temp5=0x01;temp6=0x01;temp7=0x01;temp8=0x01;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 12
for(j=0;j<ms;j++)
{
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L1=1;delay(1);L1=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L2=1;delay_ms(1);L2=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x10;temp2=0x10;temp3=0x10;temp4=0x10;temp5=0x10;temp6=0x10;temp7=0x10;temp8=0x10;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x08;temp2=0x08;temp3=0x08;temp4=0x08;temp5=0x08;temp6=0x08;temp7=0x08;temp8=0x08;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x05;temp2=0x05;temp3=0x05;temp4=0x05;temp5=0x05;temp6=0x05;temp7=0x05;temp8=0x05;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x02;temp2=0x02;temp3=0x02;temp4=0x02;temp5=0x02;temp6=0x02;temp7=0x02;temp8=0x02;xuat();L8=1;delay_ms(1);L8=0;
}
//FAMER 13
for(j=0;j<(ms+1);j++)
{
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L1=1;delay(1);L1=0;
//temp1=0x00;temp2=0x00;temp3=0x00;temp4=0x00;temp5=0x00;temp6=0x00;temp7=0x00;temp8=0x00;xuat();L2=1;delay(1);L2=0;
temp1=0x80;temp2=0x80;temp3=0x80;temp4=0x80;temp5=0x80;temp6=0x80;temp7=0x80;temp8=0x80;xuat();L3=1;delay_ms(1);L3=0;
temp1=0x40;temp2=0x40;temp3=0x40;temp4=0x40;temp5=0x40;temp6=0x40;temp7=0x40;temp8=0x40;xuat();L4=1;delay_ms(1);L4=0;
temp1=0x20;temp2=0x20;temp3=0x20;temp4=0x20;temp5=0x20;temp6=0x20;temp7=0x20;temp8=0x20;xuat();L5=1;delay_ms(1);L5=0;
temp1=0x11;temp2=0x11;temp3=0x11;temp4=0x11;temp5=0x11;temp6=0x11;temp7=0x11;temp8=0x11;xuat();L6=1;delay_ms(1);L6=0;
temp1=0x0a;temp2=0x0a;temp3=0x0a;temp4=0x0a;temp5=0x0a;temp6=0x0a;temp7=0x0a;temp8=0x0a;xuat();L7=1;delay_ms(1);L7=0;
temp1=0x04;temp2=0x04;temp3=0x04;temp4=0x04;temp5=0x04;temp6=0x04;temp7=0x04;temp8=0x04;xuat();L8=1;delay_ms(1);L8=0;
}
}
}
void tat()
{
hienthi(0x00);
hienthi(0x00);
hienthi(0x00);
hienthi(0x00);
hienthi(0x00);
hienthi(0x00);
hienthi(0x00);
hienthi(0x00);
chot=0; //xuat du lieu ra output
chot=1;
}
void main(void)
{
PORTA=0x00;
DDRA=0xFF;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x07;
PORTD=0x00;
DDRD=0x00;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
TIMSK=0x00;
ACSR=0x80;
SFIOR=0x00;
while (1)
{tat();
khung1(1,3);
luonsong(1,5);
pittong(100,1);
pittong2(100,1);
danglen(100,1);
pittong(100,1);
pittong2(100,1);
danglen(100,1);
pittong(100,1);
luonsong(1,5);
pittong2(100,1);
danglen(100,1);
};
}
( File code)
Khi nhấn nút "Tải Về Máy", bạn sẽ vào trang quảng cáo, vui lòng chờ 5 giây. Nút hiện ra ở góc phải phía trên, nhấn vào để đến trang download
Nhiều bạn kêu là không có mạch nguyên lý để làm thử, chip đọc lại code và vẽ mạch Mô Phỏng như sau, đã test trên Matrix chạy rồi, các bạn làm thử nhé..
( File Mạch MP)
Khi nhấn nút "Tải Về Máy", bạn sẽ vào trang quảng cáo, vui lòng chờ 5 giây. Nút hiện ra ở góc phải phía trên, nhấn vào để đến trang download
Nguồn: Echipkool.com - Chia sẻ kiến thức - Kết nối đam mê điện tử
Đăng nhận xét