51单片机程序——按键控制数码管程序0-999递增
#define DataPort P0
#define CtrlPort P1
#define uint unsigned int
unsigned char code DuanMa[10]={0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8,0x80,0x90};// 显示段码值0~9
unsigned char code WeiMa[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//分别对应相应的数码管点亮,即位码
unsigned char TempData[8];
sbit key=P3^1;
void Delay(unsigned int t); //函数声明
void Display(unsigned char FirstBit,unsigned char Num);
void delay1(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main (void)
{
// DuanMa=0xff;
while(1)
{
if(key==0)
{
delay1(5);
if(key==0)
{
a++;
while(!key);
}
}
TempData[0]=DuanMa[a];
Display(0,3);
}
void Delay(unsigned int t)
{
}
void Display(unsigned char FirstBit,unsigned char Num)
{
}
51单片机按键控制数码 相关文章:
- 51单片机程序——按键控制单个数码管显示(11-23)
- 51单片机程序——按键控制数码管变化(11-23)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)