Make Electronics

(nextflipdebug2) #1

Experiment 35: Checking the Real World


310 Chapter 5


FundAmentAls


Extra   features
A complete guide to the 08M would fill a book of its own, and of course such
books already exist (just search the books section of Amazon.com for keyword
“picaxe”). But I’ll finish my introduction to the controller by listing some of its
extra capabilities, leaving you to look them up and explore them. Then I’m go-
ing to suggest one last experiment.
Interrupts
The PICAXE 08M allows you to set one “interrupt.” This feature tells the chip
to make a mental note that if a particular event occurs—such as a switch
applying voltage to one pin—it should stop doing whatever else it was
doing, and respond to the interruption.
Infrared
One pin on the PICAXE 08M can be used to receive infrared signals from
a TV-style remote that you can buy from the same suppliers that sell the
PICAXE itself. With an infrared sensor attached to the chip, you can issue
commands remotely. If you want to build a remote-controlled robot, the
chip is specifically designed with this in mind.
Servo motors
Every PICAXE chip has at least one pin that can send a stream of pulses to
control a typical servo motor. On the 08M chip, it’s Logic Pin 2. The width of
each pulse tells the motor how far to rotate from its center position before
stopping. A 555 timer can send this stream, but the PICAXE makes it easier.
You can search online for more information about servo motors, which are
especially useful for applications such as steering model vehicles, adjusting
the flaps on model airplanes, and actuating robots.
Music
The PICAXE has an onboard tone generator that can be programmed with
a “tune” command to play tunes that you write using a simple code.
Alphanumeric input/output
The “kbin” programming command is available in the PICAXE models 20X2,
28X1 and 28X2, and 40X1 and 40X2. You can plug a standard computer
keyboard into the chip, and it will read the keypresses. You can also attach
alphanumeric displays, but these procedures are nontrivial. For instance,
when you’re trying to figure out which key someone has pressed on a key-
board, your program has to contain a list of the special hexadecimal codes
that the keyboard creates.
Pseudorandom number generation
All PICAXE models can generate pseudorandom numbers using a built-in al-
gorithm. If you initialize the number generator by asking the user to press a
button, and you measure the arbitrary time that this takes, you can seed the
pseudorandom number generator with the result, and the pseudorandom
number generator will have a less repeatable sequence.
Visit http://www.rev-ed.co.uk/docs/picaxe_manual1.pdf to learn more.
Free download pdf