Make Electronics

(nextflipdebug2) #1
What Next? 301

Experiment 34: Hardware Meets Software

If you detect the voltage, the software is installed and working properly. In
that case, there’s a problem on your breadboard, either in the chip or in the
wiring around it.


If you cannot detect any voltage, the software probably wasn’t installed prop-
erly, or is looking for the wrong serial port. Try uninstalling it and reinstalling it.


Your First Program


Finally you’re ready to create your first program. Type the following code into
the Programming Editor window:


main:
high 1
pause 1000
low 1
pause 1000
goto main

Be sure to include the colon after the word “main” on the first line. See Figure
5-136 for a screenshot. The indents are created by pressing the Tab key. Their
only purpose is to make program listings more legible. The software ignores
them.


Figure 5-136. This screenshot shows the first test program as it should be displayed by the
Programming Editor (on a Windows computer).


Click the Program button in the Programming Editor to download this program
into the chip. As soon as the download is complete, the chip should start flash-
ing the LED, lighting it for 1 second and then switching it off for 1 second. Figure
5-137 shows the steps that you should have followed to program the chip.


Now for the interesting part: disconnect the USB cable from the breadboard.
The chip should continue flashing.


Disconnect the power supply from the breadboard and wait a minute or two
for the capacitors to lose their charge. Reconnect the power, and the chip will
start flashing again.


The program that you downloaded to the chip will remain in the memory in-
side the chip and will begin running every time power is applied to the chip.


a: To computer
b: From computer
c: Negative power
Figure 5-135. The stereo plug on the end of
the USB download cable can be used for
fault tracing. A multimeter set to measure
DC volts can be attached to sections b and
c of the plug to establish whether the Pro-
gramming Editor is sending data through
the serial connection.

Type a program
using the
Program Editor

Click the
PROGRAM button
to download it

The PICAXE
starts running
the program

You can now
unplug the
stereo plug

Figure 5-137. Four steps to create and run a
program on the PICAXE controller chip.
Free download pdf