Traffic lights debugger

Use keil 4 to write the code to complete the crossing traffic lights debugging, code is as follows: 

#include <reg52.h> #include " delay.h " sbit W_E_R = P0 ^ 0 ; // red things sbit W_E_Y = P0 ^ 1 ; // something yellow the sbit W_E_G P0 ^ = 2 ; // things green the sbit N_S_R = P0 ^ . 3 ; // north-south red the sbit N_S_Y = P0 ^ . 4 ; // north-south yellow the sbit N_S_G = P0 ^ . 5 ; // north-south green void main() { unsigned char I; // four red light crossing W_E_R = 0 ; N_S_R = 0; delay1s(); // traffic lights work cycle the while ( 1 ) { // something red light, green light north and south, 10s delay W_E_R = 0 ; N_S_R = 1; N_S_G = 0; delay10s(); // something flashing red light, yellow light flashing north and south, 3s delay for (I = 0 ; I < . 3 ; I ++ ) { W_E_R = 0 ; N_S_Y = 0; N_S_G = 1; delay1s(); W_E_R = 1 ; N_S_Y = 1; delay1s(); } // something green light, red light north and south, 10s delay W_E_G = 0 ; N_S_R = 0; delay10s(); W_E_G = 1; N_S_R = . 1 ; // something flashing yellow, north-south red flash, 3s delay for (I = 0 ; I < . 3 ; I ++ ) { W_E_Y = 0; N_S_R = 0; delay1s(); W_E_Y = 1; N_S_R = 1; delay1s(); } } }

 

Guess you like

Origin www.cnblogs.com/yozora/p/11666076.html