10
PICAXE-08 ALARM PROJECT
revolution
© copyright 2002 - AXE102 Alarm Student Project Notes Version 1.1
Revolution Education Ltd. Email: [email protected] Web: www.rev-ed.co.uk
10
Supported by:
Testing the LED connection.
After connecting the LED it can be tested by a simple program like this:
main:
high 0
wait 1
low 0
wait 1
goto main
This program would switch the LED (connected to
output pin 0) on and off every second. If the LED does
not work check:
1) the LED is connected the correct way around
2) the correct resistor is used
3) the correct output pin number is being used in the
program
4) all the solder joints are good
This program flashes the LED connected to output pin 0 on and off 15 times using a
BASIC programming technique called a for...next loop (this technique cannot be used
with flowcharts). The number of times the code has been repeated is stored in the
memory of the PICAXE chip using a ‘variable’ called b1 (the PICAXE contains 14
variables labelled b0 to b13). A variable is a ‘number storage position’ inside the
microcontroller than the microcontroller can use to store numbers as the program is
carried out.
main:
for b1 = 1 to 15
start a for...next loop
high 0
switch pin 0 high
pause 500
wait for 0.5 second
low 0
switch pin 0 low
pause 500
wait for 0.5 second
next b1
end of for...next loop
end
end program
start
high 0
low 0
wait 1
wait 1