25
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
25
Supported by:
S
ECTION
4
P
ROGRAMMING
- BASIC
Programming in BASIC is more powerful than using flowcharts. This is because BASIC
contains more commands, eg. for...next loops, which cannot be used with the graphical
flowchart methods. However you have to be more accurate in your ‘typing’ as no spelling
mistakes are allowed!
The following program is a sample BASIC program which switches output 0 on and off
every second. When you download the program an LED connected to output 0 would
flash on and off every second.
main:
high 0
pause 1000
low 0
wait 1
goto main
This program uses the
high
and
low
commands to control output pin 0, and uses the
pause
and wait commands to make a delay. Wait uses whole second units, whilst pause
uses 1 millisecond (ms) units (1000 ms = 1 second). Therefore in this program both the
delays are the same, just written in different ways.
The last
goto
main
command makes the program ‘jump’ back to the label
main:
at the
start of the program. This means the program loops forever. Note that the first time the
label is used it must be followed by the colon (:) symbol. This tells the computer the
word is a new label.