微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机点阵LED灯

单片机点阵LED灯

时间:11-21 来源:互联网 点击:
电路图如下:


代码如下:

#include

unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

//unsigned char code tab[]={0x7f,0xbf,0xdf,0xef,0xfe,0xfd,0xfb,0xf7};

unsigned char code graph[3][8]={ {0x21,0x32,0xac,0x6c,0x32,0x21,0x3a,0x7f},

{0x00,0x02,0x04,0x0a,0xff,0x08,0x04,0x02},

{0xe1,0x55,0x55,0xdf,0x55,0x55,0x43,0x71}

};

unsigned char count;

unsigned char cnta;

sbit P1_0 = P1^0;

void main(void) {

unsigned char i,j;

TMOD=0x01;

TH0=(65536-4000)/256;

TL0=(65536-4000)%6;

TR0=1;

ET0=1;

EA=1;

while(1) {

if(P1_0==0) {

for(i=5;i>0;i--)

for(j=248;j>0;j--);

if(P1_0==0) {

count++;

if(count==3) {

count=0;

}

while(P1_0==0);

}

}

}

}

void t0(void) interrupt 1 using 0 {

TH0=(65536-4000)/256;

TL0=(65536-4000)%6;

P2=tab[cnta];

P3=graph[count][cnta];

cnta++;

if(cnta==8) {

cnta=0;

}

}


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top