專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

8*8點(diǎn)陣流水顯示I 愛心“U”

作者:佚名   來源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2012年01月02日   【字體:

本程序已經(jīng)測試通過,首發(fā)于51hei單片機(jī)網(wǎng),電路很簡單我就不畫圖了
點(diǎn)陣有16個(gè)腳位,8個(gè)是行,8個(gè)是列,接法就是行接在P1口,列接P2口
以下是程序代碼:
 

#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned int
code 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();
 }
}
關(guān)閉窗口

相關(guān)文章