Experiment 8 Traffic Light Control (80C51 MCU Assembly Language Programming)

Publisher:CelestialSoulLatest update time:2016-01-07 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Design a traffic light control system to control the red, yellow and green lights in the east-west direction and the red, yellow and green lights in the north-south direction. It can be controlled manually or automatically. Set two input control switches (P1.0 and P1.1 can be used as input control). The control process is as follows: East 
                -West Direction                  North-South Direction
P1.0  P1.1     Red  Yellow Green     Red  Yellow Green 1  0  On  for 3S then on 0  1  On for 3S then on 0  0  On  1  1  Flash (On for 1S and Off for 1S)  Flash (On for 1S and Off for 1S) ORG 0000H AJMP MAIN ORG 000BH AJMP T0 ORG 0030H MAIN:MOV P1,#03H MOV TMOD,#01H MOV TH0,#3CH MOV TL0,#0B0H SETB EA SETB ET0 MOV R2,#30 MOV R3,#30 MOV R4,#50 MOV R5,#50 MOV R6,#10 MOV R7,#10 SETB TR0 SJMP $ ORG 0200H;Enter the timer, first judge the situation T0:SETB P1.0 SETB P1.1 JB P1.0,AA;Judge the situation every 100ms JNB P1.0,BB AA:JB P1.1,SHAN;11 JNB P1.1,ZD2;01 BB:JB P1.1,ZD1  ;10 JNB P1.1,HONG;00 SHAN:MOV TH0,#3CH;Yellow light flashing situation MOV TL0,#0B0H CJNE R6,#00H,LOOP1 MOV P1,#01001011B;Light up for one second DJNZ R7,GORET1 MOV R6,#0AH GORETI:RETI LOOP1:MOV P1,#00000011B;Off for one second DJNZ R6,GORET1 MOV R7,#0AH GORET1:RETI HONG:MOV TH0,#3CH ;Red light is always on MOV TL0,#0B0H MOV P1,#10010000B RETI ZD1:JB P1.4,ZD11 MOV TH0,#3CH;Automatic situation MOV TL0,#0B0H CJNE R4,#00H,LOOP2 MOV P1,#10001001B;Yellow light is on for 3 seconds DJNZ R2,GORET2 MOV R4,#50 LJMP ZD11 LOOP2:MOV P1,#10000101B;Red light is on for 5 seconds DJNZ R4,GORET2 MOV R2,#1EH GORET2:RETI ZD11:MOV TH0,#3CH ;Automatic situation 11 MOV TL0,#0B0H CJNE R4,#00H,LOOP5 MOV P1,#01010001B; Yellow light on for 3 seconds DJNZ R2,GORET3 MOV R4,#32H MOV P1,#10000110B AJMP ZD1 LOOP5:MOV P1,#00110001B; Green light on for 5 seconds DJNZ R4,GORET3 MOV R2,#1EH GORET3:RETI ZD2:JB P1.7,ZD21 MOV TH0,#3CH ; Automatic situation 2 MOV TL0,#0B0H CJNE R5,#00H,LOOP3 MOV P1,#01010010B; Yellow light on for 3 seconds DJNZ R3,GORET4 MOV R5,#32H AJMP ZD21 LOOP3:MOV P1,#00110010B;Green light on for 5 seconds DJNZ R5,GORET4 MOV R3,#1EH GORET4:RETI ZD21:MOV TH0,#3CH;Automatic situation MOV TL0,#0B0H CJNE R5,#00H,LOOP6 MOV P1,#10001010B;Yellow light on for 3 seconds DJNZ R3,GORET5 MOV R5,#32H                  
                                            
                       
                            
                          
 




 


    
    
    
    
    
    
    
    
    
    
    
    
    
 


  
  
  

  

  
 

    
    
    
    
    
    
 
       
       
  
 

    
    
    
 

   
   
   
   
   
   
   
 
       
       
    
 
 
   
   
   
   
   
   
   
 
       
       
     
 

   
   
   
   
   
   
   
 
       
       
       
 
 
   
   
   
   
   
   MOV P1,#00110010B
   AJMP ZD2
 LOOP6:MOV P1,#10000110B; Red light on for 5 seconds
       DJNZ R5,GORET5
       MOV R3,#1EH
    GORET5:RETI
Reference address:Experiment 8 Traffic Light Control (80C51 MCU Assembly Language Programming)

Previous article:Experiment 9: Timing, counting, and display (80C51 single-chip computer assembly language programming)
Next article:Experiment 7 Serial Communication (80C51 MCU Assembly Language Programming)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号