Experiment 34: Hardware Meets Software
302 Chapter 5
Decoding the Code
Let’s take a look at the little program that you typed in. The first line identifies
a section of the program. This program only has one section, and we’re calling
it “main.” Any word with a colon after it is the name of a section of a program:
main:
The second line tells the chip to send a high output from Logic Pin 1:
high 1
The third line of the program tells the chip to wait for 1,000 milliseconds. This
of course is the same as one second:
pause 1000
The fourth line tells the chip to change Logic Pin 1 back to its low state:
low 1
The fifth line tells the chip to wait for another 1,000 milliseconds:
pause 1000
The last line tells the chip to go back to the beginning of the “main” section:
goto main
1
2
3
4 5
6
7
8
PICAXE
08M
(Logic Pin 0)
Logic Pin 1
Logic Pin 2
Logic Pin 4
Logic Pin 3
Figure 5-138. The conventional pin numbers of the PICAXE chip are incompatible with the
numbering system that is used in the PICAXE programming language. To minimize confu-
sion, this guide refers to “Logic Pins” when using the numbering system that is required
for programming the chip.
In from Computer
Out to Computer
Digital Output Pin0
Infra-Red Output
Digital Output Pin1
Digital Input Pin1
Analog-Digital Converter Pin1
Digital Output Pin2
Digital Input Pin2
Analog-Digital Converter Pin2
Motor Power Output Pin2
Tune Output
Digital Output Pin4
Digital Input Pin4
Analog-Digital Converter Pin4
Digital Input Pin3
Infra-Red Input
1
2
3
4 5
6
7
8
PICAXE
08M
Figure 5-139. Many of the pins on the PICAXE 08M have multiple functions, which can be
selected by appropriate program instructions.
The program doesn’t use the usual
pin numbers on the chip. It uses
what I will call “logic pin numbers.”
Figure 5-138 shows how they are
numbered. Figure 5-139 shows their
multiple functions. I have put Logic
Pin 0 in parentheses because its main
purpose is to send data to the com-
puter through the USB cable. It can
do double duty as a digital output,
but you have to disconnect it from
the USB cable first. It’s easy to forget
to do this. It’s a hassle that I prefer to
avoid.