2948600737 发表于 2022-11-30 21:45:50

数码管显示

昨天编了一个程序解决动态显示0~F的流动显示方法,可能还需改进#include <reg51.h>
unsigned char code table[]={0xC0,0xF9,0xA4,0xB0,0x99, //0~4
    0x92,0x82,0xF8,0x80,0x90, //5~9
    0x88,0x83,0xA7,0xA1,0x86,0x8E}; //A~F      
unsigned char code wei[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
unsigned char temp,temp0,temp1,temp2,temp3,temp4,temp5,j;
unsigned char emp,emp0,emp1,emp2,emp3,emp4,emp5,emp6,emp7,
    emp8,emp9,emp10,emp11,emp12,emp13,emp14,emp15;
void delay();
void delay1();
void main()
{{      
temp=0;
temp0=0;
temp1=1;
temp2=2;
temp3=3;
temp4=4;
temp5=5;
emp=0;
emp0=0;
emp1=1;
emp2=2;
emp3=3;
emp4=4;
emp5=5;
emp6=6;
emp7=7;
emp8=8;
emp9=9;
emp10=10;
emp11=11;
emp12=12;
emp13=13;
emp14=14;
emp15=15;

loop2:
j=40000;
   loop1:
   P3=0xff;
   P0=table;
   P3=wei;
   delay();
   P3=0xff;
   P0=table;
   P3=wei;
   delay();
   P3=0xff;
   P0=table;
   P3=wei;
   delay();
   P3=0xff;
   P0=table;
   P3=wei;
   delay();
   
   P3=0xff;
   P0=table;
   P3=wei;
   delay();
   P3=0xff;
   P0=table;
   P3=wei;
   delay();
j=j-1;
   if(j>0)
   goto loop1;
   else
   /*temp=temp0;
   temp0=temp1;
   temp1=temp2;
   temp2=temp3;
   temp3=temp4;
   temp4=temp5;
   temp5=temp;*/
   emp=emp0;
   emp0=emp1;
   emp1=emp2;
   emp2=emp3;
   emp3=emp4;
   emp4=emp5;
   emp5=emp6;
   emp6=emp7;
   emp7=emp8;
   emp8=emp9;
   emp9=emp10;
   emp10=emp11;
   emp11=emp12;
   emp12=emp13;
   emp13=emp14;
   emp14=emp15;
   emp15=emp;
   goto loop2;
}}
//延时程序
voiddelay()            //延时程序
    {
   int i;               //定义整形变量
   for(i=0x100;i--;)
;   //延时
    }会C语言的会觉得比较简单,暂时还没研究程序中temp和emp比较简洁的处理方法,http://c.51hei.com/a/old/up/0/4122711173897142.jpg

power3 发表于 2022-12-1 08:17:09

hzbaige 发表于 2022-12-1 08:29:10

谢谢分享

leslie_aqiang 发表于 2022-12-1 08:45:25

lucas陈 发表于 2022-12-1 08:45:36

huangchang 发表于 2022-12-1 08:50:26

支持一下!

wangyitu 发表于 2022-12-1 08:57:08

想起来很多年前电子市场柜台上各种的显示灯

13131 发表于 2022-12-1 08:58:02

lf2k2022 发表于 2022-12-1 09:16:04

cyzhang4_09 发表于 2022-12-1 09:34:33

页: [1] 2 3
查看完整版本: 数码管显示