#include "reg52.h"
#define uchar unsigned char
#define unit unsigned int
sbit K3=P3^2;
sbit K4=P3^3;
sbit wei=P0^7;
sbit duan=P2^2 ;
uchar code leddata []={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f ,0x77,0x7c,0x39,0x5e,0x79,0x71,0x76,0x38,0x37,0x3e,0x73,0x5c,0x40,0x00,0x00} ;
void delay(unit z)
{
unit x,y;
for(x = z ; x > 0; x--)
for(y=114 ; y > 0 ; y--);
}
void main()
{
uchar num;
wei = 1;
P0= 0xfe;
wei = 0;
while(1)
{
duan = 1;
P0= leddata[num];
duan=0;
if(K3 ==0)
{ delay(50);
if(K3 == 0)
{
num ++;
}
}
while(!K3);
if(K4 == 0){
delay(50);
if(K4 == 0){
num --;}
}
while(!K4);
if(num > 99){
num = 0;
}
if(num < 0){
num = 99;
}
}
}
求大佬看下代码哪错了,在板子上只能显示成这样,而且10位后就显示不出来了
#define uchar unsigned char
#define unit unsigned int
sbit K3=P3^2;
sbit K4=P3^3;
sbit wei=P0^7;
sbit duan=P2^2 ;
uchar code leddata []={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f ,0x77,0x7c,0x39,0x5e,0x79,0x71,0x76,0x38,0x37,0x3e,0x73,0x5c,0x40,0x00,0x00} ;
void delay(unit z)
{
unit x,y;
for(x = z ; x > 0; x--)
for(y=114 ; y > 0 ; y--);
}
void main()
{
uchar num;
wei = 1;
P0= 0xfe;
wei = 0;
while(1)
{
duan = 1;
P0= leddata[num];
duan=0;
if(K3 ==0)
{ delay(50);
if(K3 == 0)
{
num ++;
}
}
while(!K3);
if(K4 == 0){
delay(50);
if(K4 == 0){
num --;}
}
while(!K4);
if(num > 99){
num = 0;
}
if(num < 0){
num = 99;
}
}
}
求大佬看下代码哪错了,在板子上只能显示成这样,而且10位后就显示不出来了