8*8點陣流水顯示I 愛心“U”
點陣有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();}}
評論