码迷,mamicode.com
首页 > 其他好文 > 详细

点阵显示心型

时间:2017-10-12 01:01:53      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:main   static   reg   ++   unsigned   sig   nbsp   code   i++   

心形图案

#include<reg52.h>

 //绑定位

sbit ADDR0 = P1^0;

sbit ADDR1 = P1^1;

sbit ADDR2 = P1^2;

sbit ADDR3 = P1^3;

sbit ENLED = P1^4;

 

unsigned char code LedChar[] = {  //点阵显示字符转换表

     0xff,0x99,0x00,0x00,0x00,0x81,0xc3,0xe7//实心

//空心(0x99,0x66,0x7E,0x7E,0xBD,0xDB,0xE7,0xFF),case  7:需注释

};

void main(){

         EA=1;

         ADDR3=0;        //使能U4

         ENLED=0;

 

         TMOD=0x01; //使能T0为模式1

         TH0=0xFC;  // 为T0赋初始值

     TL0=0x67;

         ET0=1;         //使能中断

         TR0=1;        //开启T0

         while(1); 

}

/**

中断处理

*/

void InterRupt() interrupt 1{

           static  unsigned char i=0;

           TH0=0xfc;

           TL0=0x67;

           P0=0xff;//清屏

           switch(i){//点阵显示循环图案部分

                case 0: ADDR2 = 0; ADDR1 = 0; ADDR0 = 0; i++; P0=LedChar[0]; break;

                   case 1: ADDR2 = 0; ADDR1 = 0; ADDR0 = 1; i++; P0=LedChar[1]; break;

                   case 2: ADDR2 = 0; ADDR1 = 1; ADDR0 = 0; i++; P0=LedChar[2]; break;

                   case 3: ADDR2 = 0; ADDR1 = 1; ADDR0 = 1; i++; P0=LedChar[3]; break;

                  case 4: ADDR2 = 1; ADDR1 = 0; ADDR0 = 0; i++; P0=LedChar[4]; break;

                   case 5: ADDR2 = 1; ADDR1 = 0; ADDR0 = 1; i++; P0=LedChar[5]; break;

                   case 6: ADDR2 = 1; ADDR1 = 1; ADDR0 = 0; i++; P0=LedChar[6]; break;

                   case 7: ADDR2 = 1; ADDR1 = 1; ADDR0 = 1; i=0; P0=LedChar[7]; break;

                  

           }

}

点阵显示心型

标签:main   static   reg   ++   unsigned   sig   nbsp   code   i++   

原文地址:http://www.cnblogs.com/robotes/p/7653478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!