Well, ok.
But I accept no responsibility for the resulting accidents.
Code:@ device INTOSCIO, WDT_OFF, PWRT_OFF, MCLR_OFF, PROTECT_OFF, CPD_OFF DEFINE OSCCAL_1K 1 Green CON 5000 ; mS to show Green Light Yellow CON 1000 ; mS to show Yellow Light Tcalibrate CON 480 ; Adjust for loop timing accuracy ;--------------------- Sequence VAR BYTE ; cycles through the 4 states TimeCount VAR WORD ; Counts down sequence time CMCON = 7 ; Disable comparator GPIO = %110000 ; Start with all LED's off TRISIO = %001000 ; Set LED ports to output ;--------------------------------------------------------------------------- Main: FOR Sequence = 0 to 3 LOOKUP2 Sequence,[ Green, Yellow, Green, Yellow], TimeCount REPEAT ; Multiplex LOOKUP Sequence,[%100001,%100011,%100100,%100100],GPIO ; Tr. Light #1 PauseUS Tcalibrate LOOKUP Sequence,[%010100,%010100,%010001,%010011],GPIO ; Tr. Light #2 PauseUS Tcalibrate TimeCount = TimeCount - 1 UNTIL TimeCount = 0 NEXT Sequence GOTO Main
Last edited by Darrel Taylor; - 4th November 2008 at 03:24. Reason: added OSCCAL_1K
DT
Pleeeeeeease don't install these traffic lights in Colorado.
My wife thinks;
Green = go
Yellow = go really fast
Red = stop if you can
Would really screw up the natural order of things..;o}
Just change the numbers in the LookUp's.
LOOKUP Sequence,[%100001,%100011,%100100,%100100],GPIO ; Tr. Light #1
Code:%100001 || ||| || ||Red || |Yellow || Green |0=Tr.Light #1 0=Tr.Light #2
DT
Ready already got!.
Last edited by Leonardo; - 5th November 2008 at 23:43.
I didn't see that you edited your post.
Oh well, I needed the Flash practice anyway.
<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="600" HEIGHT="400" ><PARAM NAME="MOVIE" VALUE="http://www.pbpgroup.com/files/TrafficLight.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="true"><PARAM NAME="QUALITY" VALUE="high"><EMBED SRC="http://www.pbpgroup.com/files/TrafficLight.swf" WIDTH="600" HEIGHT="400" PLAY="true" LOOP="true" WMODE="opaque" QUALITY="high" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>
DT
Bookmarks