51單片機(jī):8x8點(diǎn)陣顯示心形圖案
單片機(jī)開發(fā)板是自己做的,電路很簡單8*8點(diǎn)陣的行和列分別接在單片機(jī)的p0口和p1口,p0口記得要上拉電阻哦,我測試成功見圖片,
#include reg52.H>unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};unsigned char code graph[]={0x30,0x48,0x44,0x22,0x44,0x48,0x30,0x00};unsigned char cnta;void main(void){unsigned int i,j;TMOD=0x01;TH0=(65536-2000)/256;TL0=(65536-2000)%256;TR0=1;ET0=1;EA=1;while(1){}}void t0(void) interrupt 1 using 0{TH0=(65536-2000)/256;TL0=(65536-2000)%256;P1=tab[cnta];P0=graph[cnta];cnta++;if(cnta==8){cnta=0;}}
評論