#include "reg52.h"
sbit KEY_SB1 = P3 ^ 3;
sbit KEY_SB2 = P3 ^ 2;
sbit KEY_SB3 = P3 ^ 1;
sbit KEY_SB4 = P3 ^ 0;
unsigned char gucLit;
unsigned char gucBlank;
void LED_Flash(void);
void Delay(void);
void main()
{
gucBlank = 0;
P1 = 0x0F; // 怀疑这里你写错了
if (KEY_SB1 == 0)
{
gucLit = 0x0C;
LED_Flash();
}
P1 = 0xF0;
if (KEY_SB2 == 0)
{
gucLit = 0x09;
LED_Flash();
}
P1 = 0xF0;
if (KEY_SB3 == 0)
{
gucLit = 0x0F;
LED_Flash();
}
P1 = 0xF0;
if (KEY_SB4 == 0)
{
gucLit = 0x03;
LED_Flash();
}
}
void LED_Flash()
{
unsigned char i = 0x10;
for (i = 0x10; i; i--)
{
P1 = gucLit;
Delay();
P1 = gucBlank;
Delay();
}
}
void Delay()
{
unsigned char i, j;
for (i = 255; i; i--)
for (j = 255; j; j--);
}