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

点阵滚动显示“我等你”的首字母

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

标签:[1]   变量声明   ase   0x03   signed   unsigned   efault   主函数   inter   

//"IWY"(左移)

#include<reg52.h>

 /**绑定IO地址

 */

 sbit ADDR0 = P1^0;

 sbit ADDR1 = P1^1;

 sbit ADDR2 = P1^2;

 sbit ADDR3 = P1^3;

 sbit ENLED = P1^4;

//字符数组声明

 unsigned char code LedChar[34][8]={ //存放所有的帧

         {0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F},

         {0xFF,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F},

         {0xFF,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F},

         {0xFF,0x0F,0x3F,0x3F,0x3F,0x3F,0x3F,0x0F},

         {0xFF,0x07,0x9F,0x9F,0x9F,0x9F,0x9F,0x07},

         {0xFF,0x03,0xCF,0xCF,0xCF,0xCF,0xCF,0x03},

         {0xFF,0x81,0xE7,0xE7,0xE7,0xE7,0xE7,0x81},

         {0xFF,0x40,0xF3,0xF3,0xF3,0xF3,0xF3,0xC0},

         {0xFF,0xA0,0x79,0x79,0x79,0x79,0xF9,0xE0},

         {0xFF,0xD0,0xBC,0xBC,0xBC,0xBC,0x7C,0xF0},

         {0xFF,0xE8,0xDE,0xDE,0xDE,0xDE,0xBE,0x78},

         {0xFF,0xF4,0xEF,0xEF,0xEF,0xEF,0x5F,0xBC},

         {0xFF,0xFA,0x77,0x77,0x77,0x77,0xAF,0xDE},

         {0xFF,0x7D,0xBB,0xBB,0xBB,0xBB,0xD7,0xEF},

         {0xFF,0xBE,0x5D,0x5D,0x5D,0x5D,0xEB,0xF7},

         {0xFF,0xDF,0xAE,0xAE,0xAE,0xAE,0x75,0xFB},

         {0xFF,0xEF,0xD7,0xD7,0xD7,0xD7,0xBA,0x7D},

         {0xFF,0xF7,0xEB,0xEB,0xEB,0xEB,0x5D,0xBE},

         {0xFF,0xFB,0x75,0x75,0x75,0x75,0xAE,0xDF},

         {0xFF,0x7D,0xBA,0xBA,0xBA,0xBA,0xD7,0xEF},

         {0xFF,0x7D,0xBA,0xBA,0xBA,0xBA,0xD7,0xEF},

         {0xFF,0x5F,0x6E,0xEE,0xEE,0xEE,0xF5,0xFB},

         {0xFF,0xAF,0xB7,0x77,0xF7,0xF7,0xFA,0xFD},

         {0xFF,0xD7,0xDB,0xBB,0x7B,0x7B,0x7D,0x7E},

         {0xFF,0xEB,0xED,0x5D,0xBD,0xBD,0xBE,0xBF},

         {0xFF,0x75,0x76,0xAE,0xDE,0xDE,0xDF,0xDF},

         {0xFF,0xBA,0xBB,0xD7,0xEF,0xEF,0xEF,0xEF},

         {0xFF,0xDD,0xDD,0xEB,0xF7,0xF7,0xF7,0xF7},

         {0xFF,0xEE,0xEE,0xF5,0xFB,0xFB,0xFB,0xFB},

         {0xFF,0xF7,0xF7,0xFA,0xFD,0xFD,0xFD,0xFD},

         {0xFF,0xFB,0xFB,0xFD,0xFE,0xFE,0xFE,0xFE},

         {0xFF,0xFD,0xFD,0xFE,0xFF,0xFF,0xFF,0xFF},

         {0xFF,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF},

         {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}

 };

 

         /**   主函数

         */

 void main(){

   EA=1;   //使能总中断

   ENLED = 0;  //使能IO口

   ADDR3 = 0;

   TMOD=0x01;  //使能定时器为模式1

   TH0=0xFC; //赋初始值

   TL0=0x67;

   ET0=1;                 //使能中断

   TR0=1;                //使能定时器

   while(1);

 }

        /**中断服务

         */

 void InterRupt()interrupt 1{

  //静态变量声明

        static unsigned char i = 0;

         static unsigned char num = 0;

         static unsigned int tmr = 0;

         TH0=0xFC;//重新赋值

         TL0=0x67;

         P0=0xFF; //清屏 (防止鬼影)

         switch(i){

      //每次中断刷新点阵的显示

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

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

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

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

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

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

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

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

                   default: break;

         }

         //实现换片(250ms)

         tmr++;

         if(tmr>=250){

                   tmr=0;

                   num++;

                   if(num>=34){

                            num=0;

                   }

         }

 

 }

点阵滚动显示“我等你”的首字母

标签:[1]   变量声明   ase   0x03   signed   unsigned   efault   主函数   inter   

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

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