本程序现已测试通过,首发于51hei单片机网,电路很简单我就不画图了
点阵有16个脚位,8个是行,8个是列,接法便是行接在P1口,列接P2口
以下是程序代码:
#include#define uchar unsigned char#define uint unsigned intcode uchar TAB[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x81,0xE7,0xE7,0xE7,0xE7,0xE7,0xE7,0x81,0xff, //"I"字0x99,0x00,0x00,0x00,0x00,0x81,0xC3,0xE7,0xff, //"红心"0x99,0x99,0x99,0x99,0x99,0x99,0xC3,0xE7, //"U字0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};uchar j=0,m=0;void delay(uint z){uint x,y;for(x=z;x>0;x--)for(y=125;y>0;y--);}void xianshi_hs(){ uchar i=0;P1=0x01;for(i=0;i<8;i++){P2=TAB[i+j] ;delay(2);P1<<=1;} }int_intt0() interrupt 1{TH0=(65536-50000)/256;TL0=(65536-50000)%256;m++;if(m==3){m=0;j++;if(34==j){j=0;}}}void main(){TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;while(1){xianshi_hs();}}