为什么单片机在 PROTEUS里仿真两位数码管数字会出现闪烁?
是什么问题呢?#include<reg52.h>typedefunsignedcharuint8;typedefunsignedintuint16;typedefunsi...
是什么问题呢?
#include <reg52.h>
typedef unsigned char uint8;typedef unsigned int uint16;
typedef unsigned long uint32;
unsigned char number[16] = {0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xa7,0xa1,0x86,0x8e
} ;
sbit L0 = P2^0;
sbit L1 = P2^1;
uint8 a[2];
void delay(uint16 z){
uint16 x,y;
for(x=z;x>0;x--)
for(y=114;y>0;y--);
}
void refresh_led()
{
L0 = 0;P3 = number[a[0]];delay(10);L0 = 1;P2 = 0xFF;
L1 = 0;P3 = number[a[1]];delay(10);L1 = 1;P2 = 0xFF;
}
main()
{
uint8 n = 23;
while(1)
{
delay(1);
a[0] = n%10;
a[1] = n/10%10;
refresh_led();
}
} 展开
#include <reg52.h>
typedef unsigned char uint8;typedef unsigned int uint16;
typedef unsigned long uint32;
unsigned char number[16] = {0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xa7,0xa1,0x86,0x8e
} ;
sbit L0 = P2^0;
sbit L1 = P2^1;
uint8 a[2];
void delay(uint16 z){
uint16 x,y;
for(x=z;x>0;x--)
for(y=114;y>0;y--);
}
void refresh_led()
{
L0 = 0;P3 = number[a[0]];delay(10);L0 = 1;P2 = 0xFF;
L1 = 0;P3 = number[a[1]];delay(10);L1 = 1;P2 = 0xFF;
}
main()
{
uint8 n = 23;
while(1)
{
delay(1);
a[0] = n%10;
a[1] = n/10%10;
refresh_led();
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询