Você está na página 1de 1

PICAXE products are developed and distributed by Revolution Education Ltd

Unit 2 Bath Business Park, Foxcote Ave, Bath, BA2 8SF, UK

Stoplight

Any PICAXE will work with this program.


Use a 330 ohm current limiting resistor in series with each LED
The long lead on an LED connects to the plus 5V
Great starter program to introduce commands
o high # sends 5 V to the pin designated
o low # connects the assigned pin to ground (0V)
o toggle # changes high to low or low to high for the assigned pin
o pause # stops the program for the time listed in milliseconds
o start: could be any non-reserved word and is used to break the program into sections
o Great for/next practice. It uses a memory location (b1) as a counter to flash the yellow
light five times
o goto start: sends the program back to the start: marker and it runs again

high 1
low 2
low 4

; turn on. red wired to pin 1


; turn off yellow wired to pin 2
; turn off green wired to pin 4 (pin 3 is reserved for input)

start:
pause 7000
toggle 1
toggle 4
pause 7000
toggle 4
toggle 2
pause 000
toggle 2

; begin program
; red on for 7 seconds
; turn red off
; turn green on
; green on for 7 seconds
; turn green off
; turn yellow on
; optional pause now set to zero
; turn yellow off

for b1 = 1 to 5
high 2
pause 400
low 2
high 4
pause 200
low 4
next b1

; This is a for-next loop that alternately blinks five times


; yellow on
; wait for .4 sec
; yellow off
; green on
; wait for .2 seconds
; green off
; loop until b1 > 5

high 2
pause 2500
low 2
toggle 1
goto start:

; yellow on
; yellow on steady for 2.5 seconds
; yellow off
; turn red on
; do it again from start word

Presentation by Paul Boston for GCMR Meet


February 23, 2013
paulboston@cox.net

Você também pode gostar