#include #define uchar unsigned char #define uint unsigned int sbit FMQ=P3^4; sbit QR=P2^7; sbit QY=P2^6; sbit QG=P2^5; sbit HR=P2^7; sbit HY=P2^6; sbit HG=P2^5; sbit ZR=P2^4; sbit ZY=P2^3; sbit ZG=P2^2; sbit YR=P2^4; sbit YY=P2^3; sbit YG=P2^2; sbit SWITCH1=P1^0; sbit SWITCH2=P1^1; sbit SWITCH3=P1^2; sbit SWITCH4=P1^3; sbit P3_2=P3^2; sbit P3_3=P3^3; uchar DAT1, DAT2; //display time variable uchar DISP1[2]={0,0}; //Display buffer 1, north and south uchar DISP2[2]={0,0}; //Display buffer 2, things uchar code table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xFF}; void DISPCLK1(volatile i); void DISPCLK2(volatile i); void DEL1MS(uint z) { uint x,y; for(x=0;x } void main() { flying i,j; TCON=0x5; PX1=1; EX0=1; EX1=1; EA=1; P0=0xFF; P1=0xFF; P2=0xFF; P3=0xFF; while(1) { P1=0xFF; P2=0xFF; DAT1=25; DAT2=25; QG=0; HG=0; ZR=0; YR=0; for(i=0;i<20;i++) { for(j=0;j<200;j++) { DISPCLK1(DAT1); DISPCLK2(DAT2); DEL1MS(25); //delay 5 milliseconds } FMQ=1; DAT1=DAT1-1; DAT2=DAT2-1; } P1=0xFF; P2=0xFF; ZY=0; YY=0; QY=0; HE=0; for(i = 0; i < 5; i++) { for(j = 0; j < 200; j++) { DISPCLK1(DAT1); //display DISPCLK2(DAT2); //display DEL1MS(25); //Delay 3 milliseconds } QY = ~QY; //The yellow light is on in the north-south direction HE = ~HE; ZY = ~ZY; //The yellow light is on in the east-west direction YY = ~YY; FMQ = ~FMQ; //Buzzer beeps when the light turns yellow DAT1 = DAT1 - 1; //Complete the digital subtraction operation, and send the adjusted digital to the video memory DAT2 = DAT2 - 1; //Complete the digital subtraction operation, and send the adjusted digital to the video memory } P1 = 0xff; P2 = 0xff; DAT1 = 15; //Assembly 0x20 DAT2 = 15; //Assembly 0x20 ZG = 0; //The green light is on in the east-west direction YG = 0; QR = 0; //Red light on in north-south direction HR = 0; for(i = 0; i < 10; i++) //Execute for 15 seconds { for(j = 0; j < 200; j++) { DISPCLK1(DAT1); //display DISPCLK2(DAT2); //display DEL1MS(25); //Delay 3 milliseconds } FMQ = 1; //Buzzer sounds DAT1 = DAT1 - 1; //Complete the digital subtraction operation, and send the adjusted digital to the video memory DAT2 = DAT2 - 1; //Complete the digital subtraction operation, and send the adjusted digital to the video memory } //The yellow light flashes in the last 5 seconds P1 = 0xff; P2 = 0xff; // Turn off all lights ZY = 0; //yellow light on YY = 0; QY = 0; HE = 0; for(i = 0; i < 5; i++) { for(j = 0; j < 200; j++) { DISPCLK1(DAT1); //display DISPCLK2(DAT2); //display DEL1MS(25); //Delay 3 milliseconds } QY = ~QY; //The yellow light is on in the north-south direction HE = ~HE; ZY = ~ZY; //The yellow light is on in the east-west direction YY = ~YY; FMQ = ~FMQ; //Buzzer beeps when the light turns yellow DAT1 = DAT1 - 1; //Complete the digital subtraction operation, and send the adjusted digital to the video memory DAT2 = DAT2 - 1; //Complete the digital subtraction operation, and send the adjusted digital to the video memory } } } void D_X() interrupt 0 using 0 { fly i,j,temp0,temp1,temp2,temp3; EA=0; P3_2=1; while(!P3_2); temp0=DAT1; temp1=DAT2; temp2=P1; temp3=P2; DAT1=60; DAT2=60; P1=0xff; P2=0xff; ZG=0; YG=0; QR=0; HR=0; for(i=0;i<60;i++) { for(j=0;j<200;j++) { DISPCLK1(DAT1); DISPCLK2(DAT2); DEL1MS(25); } DAT1=DAT1-1; DAT2=DAT2-1; } DAT1=temp0; DAT2=temp1; P1=temp2; P2=temp3; EA=1; } void N_B() interrupt 2 using 0 { fly i,j,temp0,temp1,temp2,temp3; EA=0; P3_3=1; while(!P3_3); temp0=DAT1; temp1=DAT2; temp2=P1; temp3=P2; DAT1=60; DAT2=60; P1=0xff; P2=0xff; ZR=0; YR=0; QG=0; HG=0; for(i=0;i<60;i++) { for(j=0;j<200;j++) { DISPCLK1(DAT1); DISPCLK2(DAT2); DEL1MS(25); } DAT1=DAT1-1; DAT2=DAT2-1; } DAT1=temp0; DAT2=temp1; P1=temp2; P2=temp3; EA=1; } void DISPCLK1(volatile i) { DISP1[0]=i%10; DISP1[1]=i/10; P0=table[DISP1[0]]; SWITCH2=0; DEL1MS(2); SWITCH2=1; P0=table[DISP1[1]]; SWITCH1=0; DEL1MS(2); SWITCH1=1; } void DISPCLK2(float i) { DISP2[0]=i%10; DISP2[1]=i/10; P0=table[DISP2[0]]; SWITCH4=0; DEL1MS(2); SWITCH4=1; P0=table[DISP2[1]]; SWITCH3=0; DEL1MS(2); SWITCH3=1; }
Previous article:Temperature and humidity detection system based on single chip microcomputer
Next article:Design of intelligent lighting control system based on single chip microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Solve the five-stage problem of embedded system signal debugging
- What is Wi-Fi 6 and why do we need it?
- Sharing: Design of an outdoor switching power supply_Simulation and experimental research
- Watch the video to win a JD card | PI Brushless DC Motor Learning Center is officially launched
- GD32L233C-START Review-(Last) Radar Overall Demonstration
- LPS22HB code porting
- Automotive electronics popular data download collection
- TI TMS320C6678 Evaluation Module
- 2018 EEWORLD technical live broadcast replay summary ~ 40+ sessions including multiple hot topics, stay at home to know the forefront of the industry
- [MPS Mall Big Offer Experience Season] Unboxing