为什么单片机在 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个回答
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
STM32是一种32位的微控制器,由意法半导体(STMicroelectronics)公司设计和生产。STM32是一种非常常见的嵌入式系统芯片,广泛应用于物联网、汽车、工业控制、医疗设备等领域。STM32具有以下特点:1. 体积小巧:STM...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询