提示这个错误怎么办?
#include <reg51.h>
#define DISP_PORT P1 // ???????
#define DISP_DATA P2 // ???????
#define NORTH_GREEN_TIME 54 // ??????
#define NORTH_YELLOW_TIME 3 // ??????
#define NORTH_RED_TIME 40 // ??????
#define EAST_GREEN_TIME 34 // ??????
#define EAST_YELLOW_TIME 3 // ??????
#define EAST_RED_TIME 60 // ??????
#define EMERGENCY_TIME 99 // ??????
sbit NORTH_GREEN_LED = P0^0; // ????
sbit NORTH_YELLOW_LED = P0^1; // ????
sbit NORTH_RED_LED = P0^2; // ????
sbit EAST_GREEN_LED = P0^3; // ????
sbit EAST_YELLOW_LED = P0^4; // ????
sbit EAST_RED_LED = P0^5; // ????
sbit KEY1 = P3^0; // ??????
sbit KEY2 = P3^1; // ??????
unsigned char north_time_left = 60; // ????????
unsigned char east_time_left = 40; // ????????
unsigned char emergency_time_left = EMERGENCY_TIME; // ????????
unsigned char disp_buf[2]; // ???????,????????
// ???????
void display(unsigned char num)
{
unsigned char i;
DISP_PORT = 0xFE; // ???????
for (i = 0; i < 8; i++) {
DISP_DATA = num % 10; // ???
num /= 10; // ???
DISP_PORT = DISP_PORT << 1; // ??
DELAY_MS(1); // ??????
}
}
// ????????,?????
void delay_ms(unsigned int ms)
{
unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 114; j++) {} // ??????,??1ms
}
}
// ??????????
void north_green()
{
north_time_left = NORTH_GREEN_TIME;
while (north_time_left > 0) {
if (north_time_left <= 3) {
// ??????
NORTH_GREEN_LED = ~NORTH_GREEN_LED;
delay_ms(500);
NORTH_GREEN_LED = 1;
delay_ms(500);
} else {
// ??????
NORTH_GREEN_LED = 1;
delay_ms(1000);
}
north_time_left--;
}
}
// ??????????
void north_red()
{
north_time_left = NORTH_RED_TIME;
NORTH_GREEN_LED = 0;
NORTH_YELLOW_LED = 0;
NORTH_RED_LED = 1;
delay_ms(NORTH_YELLOW_TIME * 1000);
NORTH_RED_LED = 0;
NORTH_YELLOW_LED = 1;
delay_ms(NORTH_YELLOW_TIME * 1000);
NORTH_YELLOW_LED = 0;
while (north_time_left > 0) {
NORTH_RED_LED = 1;
delay_ms(1000);
north_time_left--;
}
}
// ??????????
void east_green()
{
east_time_left = EAST_GREEN_TIME;
while (east_time_left > 0) {
if (east_time_left <= 3) {
// ??????
EAST_GREEN_LED = ~EAST_GREEN_LED;
delay_ms(500);
EAST_GREEN_LED = 1;
delay_ms(500);
} else {
// ??????
EAST_GREEN_LED = 1;
delay_ms(1000);
}
east_time_left--;
}
}
// ??????????
void east_red()
{
east_time_left = EAST_RED_TIME;
EAST_GREEN_LED = 0;
EAST_YELLOW_LED = 0;
EAST_RED_LED = 1;
delay_ms(EAST_YELLOW_TIME * 1000);
EAST_RED_LED = 0;
EAST_YELLOW_LED = 1;
delay_ms(EAST_YELLOW_TIME * 1000);
EAST_YELLOW_LED = 0;
while (east_time_left > 0) {
EAST_RED_LED = 1;
delay_ms(1000);
east_time_left--;
}
}
// ????????
void emergency()
{
north_time_left = 0;
east_time_left = 0;
emergency_time_left = EMERGENCY_TIME;
display(99); // ??????"99"
while (emergency_time_left > 0) {
if (emergency_time_left <= 3) {
// ??????
EAST_GREEN_LED = ~EAST_GREEN_LED;
delay_ms(500);
EAST_GREEN_LED = 1;
delay_ms(500);
} else {
// ??????
EAST_GREEN_LED = 1;
delay_ms(1000);
}
emergency_time_left--;
}
EAST_GREEN_LED = 0;
EAST_YELLOW_LED = 0;
EAST_RED_LED = 1;
delay_ms(EAST_YELLOW_TIME * 1000);
EAST_RED_LED = 0;
EAST_YELLOW_LED = 1;
delay_ms(EAST_YELLOW_TIME * 1000);
EAST_YELLOW_LED = 0;
}
int main()
{
while (1) {
// ??????
north_green();
north_red();
// ??????
east_red();
east_green();
// ??????
if (KEY1 == 0) {
emergency();
}
if (KEY2 == 0) {
north_time_left = 60;
east_time_left = 40;
}
// ??????
disp_buf[0] = north_time_left / 10;
disp_buf[1] = north_time_left % 10;
display(disp_buf[0] * 10 + disp_buf[1]); // ????????
delay_ms(1000);
disp_buf[0] = east_time_left / 10;
disp_buf[1] = east_time_left % 10;
display(disp_buf[0] * 10 + disp_buf[1]); // ????????
delay_ms(1000);
}
return 0;
}
|