Need help with Traffic Light Controller

Thread Starter

jose2529

Joined Apr 28, 2013
4
Hello,

I need help building the actual circuit on my breadboard for this project. The following is my code:

Rich (BB code):
     list    p=12F609        ; list directive to define processor
#include <p12F609.inc>      ; processor specific 

     __CONFIG    _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTOSCIO &_IOSCFS_4MHZ
    ; _MCLRE_ON enables external Reset
    ; _CP_OFF turns off "Code Protection"
    ; _WDT_OFF disables the Watchdog Timer
    ; _INTOSCIO selects the internal RC oscillator as the time base

; Variable Definitions
     UDATA    ; Beginning of Uninitialized Data

dc1        RES    1    ; delay loop counter
dc2        RES    1    ; delay loop counter
dc3        RES    1

; Code section
RESET    CODE    0x000    ; Processor resets to start of program memory


; MAIN

start
    banksel TRISIO;
    movlw b'001000'; 
    movwf TRISIO;            Setting GP0, GP1, GP2, GP4 and GP5 as inputs

    lights_cycle

        banksel GPIO;
        movlw b'100001';        
        movwf GPIO;                GNS, REW ON (Figure3)
        call delay;        2s
        call delay;        2s
        call delay;        2s
        call delay;        2s

            

        banksel GPIO;
        movlw b'100011';        
        movwf GPIO;                GaNS, REW ON (Figure4)
        call delay;        2s
        call delay;        2s
        call delay;        2s
            

        banksel GPIO;
        movlw b'100111';
        movwf GPIO;                YNS, REW ON (Figure5)
        call delay;        2s
        call delay;        2s
            ;4s delay

        banksel GPIO;
        movlw b'010110';            
        movwf GPIO;                GEW, RNS ON (Figure6)
        call delay;        2s
        call delay;        2s
        call delay;        2s
        call delay;        2s

        banksel GPIO;
        movlw b'010100';        
        movwf GPIO;                GaEW, RNS ON (Figure7)
        call delay;        2s
        call delay;        2s
        call delay;        2s
        
        banksel GPIO;
        movlw b'010000';        
        movwf GPIO;                YEW, RNS ON (Figure8)
        call delay;        2s
        call delay;        2s
    
    goto lights_cycle

        delay
            movlw     .100;
            movwf     dc1;
            movlw   .200;
            movwf    dc2;
            movlw    .07;
            movwf    dc3;

            
            dly1    nop         ; 
            decfsz    dc1,f;
            goto     dly1;
            decfsz    dc2,f;
            goto     dly1;    
            decfsz    dc3,f;
            goto     dly1;
    
        return

    END
My design should meet the following:
The order of lights should be East-West Green (8 seconds), Green Arrow (6
seconds, flashing 2 times per second, 50% duty cycle), Yellow (4 seconds),
and then Red. The North-South lights should follow in the appropriate
sequence with the same timing parameters.

Can anyone please help me with actually building the circuit please?
 
Last edited by a moderator:

Thread Starter

jose2529

Joined Apr 28, 2013
4
Sorry I forgot to mention what I'm working with.
I have 4 LEDS: Red, Yellow, Green and White(using as flashing green arrow)
1 PIC12F609 and a PICkit3 to program the PIC12F609. I have the resistors for the LEDs. Also I am planning to power the circuit with the PICkit3 itself, if not then just a 5 volt power source and ground.
Thanks again in advance.
 

tracecom

Joined Apr 16, 2010
3,944
I haven't done this exercise, and in fact, I can't read ASM code, so I couldn't do it if I wanted to. But in the absence of any other help, my suggestion is as follows.

You need to make a timing chart that shows what lights are on at exactly the same time, and what lights are never on at the same time as any other. That will tell you which lights can be connected to a single pin and which lights must have their own unique pin, and thus how many pins you need. Then, read your code and see which pins provide the timing you need. That will tell you which LEDs go on which pins.

I can't stay up any longer. Good luck.
 
Top