广告

原创 多功能点阵显示proteus程序

2009-5-14 09:39 1924 1 1 分类: MCU/ 嵌入式

http://space.ednchina.com/Upload/2009/5/14/4324c7e4-3f73-4a49-8129-7a1789756cf4.rar/*********************************************************
实现功能:1.跑马灯
   2.点阵数字1秒精确显示
   3.点阵简单图形显示   
********************************************************/
#include <reg51.h>
sbit s0=P3^0;
sbit s1=P3^1;
sbit s2=P3^2;
sbit s3=P3^3;
sbit s4=P3^4;
sbit s5=P3^5;
sbit s6=P3^6;
unsigned char code tab[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char code digittab[10][8]={0xff,0xff,0xc1,0xbe,0xbe,0xc1,0xff,0xff, //0
                                    0xff,0xff,0xff,0xff,0xde,0x80,0xfe,0xff, //1
                                    0xff,0xff,0xd8,0xba,0xba,0xba,0xc6,0xff, //2
                                    0xff,0xff,0xdd,0xb6,0xb6,0xb6,0xc9,0xff, //3
                                    0xff,0xff,0xf3,0xeb,0xdb,0x80,0xfb,0xff, //4
                                    0xff,0xff,0x8d,0xae,0xae,0xae,0xb1,0xff, //5
                                    0xff,0xff,0xc1,0xb6,0xb6,0xb6,0xd9,0xff, //6
                                    0xff,0xff,0xbf,0xbf,0xbf,0xb0,0x8f,0xff, //7
                                    0xff,0xff,0xc9,0xb6,0xb6,0xb6,0xc9,0xff, //8
                                    0xff,0xff,0xcd,0xb6,0xb6,0xb6,0xc1,0xff     //9
                                   };
unsigned char code tutab [5][8]={   0xcf,0xb7,0xbb,0xdd,0xbb,0xb7,0xcf,0xff ,   //心
                          0xed,0xeb,0xc3,0xb7,0xc3,0xeb,0xed,0xff,   //星
                                      0xff,0xff,0xc7,0xbb,0xbb,0xbb,0xc7,0xff ,   //圆
           0xfb,0xf3,0xeb,0xdb,0xb7,0xaf,0x9f,0xbf, //平行
           0xfb,0xf3,0xeb,0xdb,0xeb,0xf3,0xfb,0xff//三角形
          
                                    };                                                                                                                                                                                                          


unsigned int timecount;
unsigned char cnta;
unsigned char cntb;
#define N 253
#define M 253
void delay (int m)
{
 unsigned char i,j,k;
 for (i=0;i<m;i++)
 for (k=0;k<5;k++)
 for (j=0;j<253;j++);
}


void delay1 ()
{
  unsigned char j;
  for (j=0;j<156;j++);
}


void paomadeng ()
{
                    
  unsigned temp,a,b,i;
  temp="0xfe";
  P2=temp;
  delay(N);
  for(i=1;i<8;i++)            //从右到左移动
   {
    a="temp"<<i;
    b="temp">>(8-i);
    P2=a|b;
    delay(N);              //延时
   }
  for(i=1;i<8;i++)         //从左到右的移动
  {
    a="temp">>i;
    b="temp"<<(8-i);
    P2=a|b;
    delay(N);
  }
 }
 


 


void shuzi ()
{
   unsigned char i,j,k; 
        for (k=0;k<10;k++)
        for (j=0;j<254;j++)
  {
          for (i=0;i<8;i++)
         {
      P1=tab;
      P0=digittab[k];
      delay1 ();
           }
       }


   
   
}


void xinxing()
{
   unsigned char i;   
   for (i=0;i<8;i++)
   {
    P1=tab;
    P0=tutab[0];
    delay1 ();
   }
  
}


void yuanxing ()
{
    unsigned char i;   
   for (i=0;i<8;i++)
   {
    P1=tab;
    P0=tutab[2];
    delay1 ();
   }
}


void xingxing ()
{
   unsigned char i;   
   for (i=0;i<8;i++)
    {
      P1=tab;
      P0=tutab[1];
      delay1 ();
    }
  
}


void sjxing ()
{
   unsigned char i;   
   for (i=0;i<8;i++)
    {
      P1=tab;
      P0=tutab[4];
      delay1 ();
   }
}


void xunhuan ()
{  
    
   unsigned char i,j,k; 
        for (k=0;k<5;k++)
        for (j=0;j<254;j++)
  {
          for (i=0;i<8;i++)
         {
      P1=tab;
      P0=tutab[k];
      delay1 ();
           }
       }


      
}
void main ()
{
   P2=0xff;
  while (1)
  {
    if (s0==0)
     {
       delay (2);
     if (s0==0)
     paomadeng ();
     }


    if (s1==0)
     {
     delay (2);
     if (s1==0)
     shuzi ();
     }


    if (s2==0)
     {
      delay (2);
      if (s2==0)
      xinxing ();
     } 


     if (s3==0)
     {
      delay (2);
      if (s3==0)
      yuanxing ();
     } 


      if (s4==0)
     {
      delay (2);
      if (s4==0)
      xingxing ();
     } 
    
      if (s5==0)
     {
      delay (2);
      if (s5==0)
      sjxing ();
     } 


      if (s6==0)
     {
      delay (2);
      if (s6==0)
      xunhuan();
     } 
  }
}

广告

文章评论 0条评论)

登录后参与讨论
相关推荐阅读
aas7502987 2012-04-07 11:48
51/STC最小系统板资料(更新中)
图片欣赏    淘宝网址:http://item.taobao.com/auction/item_detail.htm?item_num_id=9073446988  二   程...
aas7502987 2011-10-13 22:59
YL-3 资料
YL-3数码管模块资料:YL-3 串行数码管资料.zip...
aas7502987 2011-09-24 09:10
USB转TTL小板驱动
xp系统驱动:XP系统支持STC下载的PL-2303HX新版驱动.rar WIN7系统驱动:WIN7系统支持STC下载的PL2303HX驱动.rar...
aas7502987 2011-05-24 22:48
STM32F103RBT6最小系统原理图 PCB
STM32F103RBT6最小系统板原理图 PCB 附件:做好的成品板:淘宝链接网址:http://item.taobao.com/item.htm?id=8864376956...
aas7502987 2011-05-08 12:53
YL-16 STM32F103最小系统板资料(更新中)
二 数据手册:  USB协议中文版:attachment download  中文数据手册:attachment downloadSTM32选型手册:attachment downloadSTM32勘...
aas7502987 2011-03-20 13:27
DS18B20温度测量模块
DS18B20 数码管温度显示程序:...
我要评论
0
1
广告
关闭 热点推荐上一条 /3 下一条