1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

traffic lights

Discussion in 'Assembly Language Programming (ALP) Forum' started by djstar, Nov 28, 2010.

  1. djstar

    djstar New Member

    Joined:
    Nov 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi , im very new to assembly langauge and im doing a unit at college on it. my assignment is to write a program that would simulate a pelican crosing. ive had a good go at writting it but when i load it into the assembler it comes up with erros.


    th sequence should go

    TURN ON GREEN LED
    DELAY
    TURN ON AMBER LED ON
    SMALL DELAY
    TURN RED LED ON AND SOUND A BUZER
    DELAY
    FLASH AMBER LED ON AND OF



    ive had a go at the program up to the buzer but im a bit confused to whi it isent workong.

    p3 is port 3 of the robot is a bank of leds and port 2.7 is the buzzer.

    if you need any more information then just say.

    many thanks laura
    Code:
    
     main1()
     
     {
     
     #pragma asm
    
    
    
    start:
    
                    mov P3, #0Dfh                 ;// turn on green led//
                    
    
        
                    mov r7, #0ffh                 ;// move ffh to reg 7 ( DELAY)//
    outerloop1:            
                    
    
                    mov r6, #0ffh                ;// move ffh to reg 6 (DELAY)//
    innerloop1:    
    
    
                    mov r5, #0ffh
    inner:        
    
                    djnz r5 inner
                    
                    djnz r6 innerloop1
                    
                    djnz r7 outerloop1
                    
                    mov P3, #0bfh                 ;// turn amber led on //
                
                
                
                
                
                    
                    mov r7, #3fh                 ;// move ffh to reg 7//
    outerloop2:                    
    
                    mov r6, #0ffh                ;// move ffh to reg 6//
    innerloop2:                
                    
                    mov r5, #0ffh
    inner2:                
                    djnz r5 inner2
                    
                    djnz r6 innerloop2
                    
                    djnz r7 outerloop2
                    
                
                    mov P3, #7fh                  ;// turn red led on //
                
                
                
    counter:        
                
                    mov P2, #80h                  ;// siren on //
    
                    ACALL, delay:                 ;//  (delay)//
                                    
                    mov P2, #00h                 ;// siren off//
                    
                    ACALL, delay:                 ;//  (delay)//
                    
                    
    
    
    
    delay:    
                                
    
                    mov r2, #0fh                ;// move ffh to reg 6//
    innerloop8:    
    
    
                    mov r1, #0ffh                ;// move ffh to reg 5//
    inner8:        
    
                    djnz r1 inner8
                    
                    djnz r2 innerloop8
                    
                    ret
                    
    counter: 
            
                
                    mov r7, #0fh                 ;// move 0fh to reg 7//
    counter1:             
                    
    
                    mov r6, #0ffh                ;// move ffh to reg 6//
    counter2:    
    
    
                    mov r5, #0ffh                ;// move ffh to reg 5//
    counter3:        
    
                    djnz r5 counter1
                    
                    djnz r6 counter2    
                    
                    djnz r7 counter3
                    
                    ret            
                
        
                    
                    mov P3, #0bfh                 ;// turn amber led on //    
                    
                    
                    
                    
    #pragma endasm
    
    }
     
    Last edited by a moderator: Nov 28, 2010
  2. livinmanavalan

    livinmanavalan Banned

    Joined:
    Dec 6, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    i dont know anything about the traffic lights. please tell me how it is working.
    is it automatic or manual?:confused:
     

Share This Page