Putting this procedure into a controller chip not only simplifies the circuit, but offers another advantage: you can change the combination simply by rewriting the program and downloading the new version into the chip.
Figure 5-148. This screenshot shows the complete listing of a program to read a sequence of three keypresses in conjunction with a combination lock. If the sequence is correct, the PICAXE sends a high output from one of its pins. If the sequence is incorrect, the program loops back to the beginning.
Fundamentals
Limitations of MCUs
The PICAXE does have some disadvantages. Its voltage requirements alone restrict you from using it with the kind of freedom of a 555 timer.
Also, although I can get an instant result by plugging a 555 timer into a breadboard and adding a couple of resistors and a couple of capacitors, the PICAXE requires me to add a download socket, hook it up to my computer, write a program in the Programming Editor, and download the program.
Some people don’t like writing software, or they have difficulty thinking in the relentlessly left-brain way that computer programming requires. They may prefer the hands-on process of assembling hardware.
Other people may have the opposite preference. This of course is a matter of taste, but one thing we know beyond all doubt is that computer programs often contain errors that may not reveal themselves until weeks or months later.
The PICAXE, for instance, doesn’t protect you if a number is assigned to a variable that exceeds the limit for that type of variable. Suppose b1=200 and b2=60 and your program tells the PICAXE:
let b3 = b1 + b2
The result should be 260, but byte-size variables can only count up to 255. What happens? You will find that b3 acquires a value of 4, without any warning or explanation. This is known as an “overflow error,” which can be very difficult to predict, because it happens at runtime, when external factors are in control. The code looks perfectly good; the Programming Editor doesn’t find any syntax errors; the simulation behaves properly. But in the real world, days or even months later, an unexpected set of circumstances results in an input that causes the overflow, and because the code is residing inside the chip at this point, you may have a hard time figuring out what on earth went wrong.
Software has its problems. Hardware has its advantages.
Fundamentals
Unexplored territory
If you’ve taken the time to complete most of the projects in this book with your own hands, you have gained a very rapid introduction to the most fundamental areas of electronics.
What have you missed along the way? Here are some topics that remain wide open for you to explore. Naturally you should search online if they interest you.
The informal, learning-by-discovery approach that I have used in this book tends to be light on theory. I’ve avoided most of the math that you’d be expected to learn in a more rigorous course on the subject. If you have mathematical aptitude, you can use it to gain a much deeper insight into the way in which circuits work.
I didn’t deal much with computer architecture, either. We didn’t go very far into binary code, and you didn’t build a half-adder, which is a great way to learn how computers function on the most fundamental level. Perhaps you should think about assembling one.
I avoided going deeply into the fascinating and mysterious properties of alternating current. Here again, some math is involved, but just the behavior of current at high frequencies is an interesting topic in itself.
For reasons already stated, I avoided surface-mount components—but you can still go into this area yourself for a relatively small investment, if you like the idea of creating fascinatingly tiny devices. This may be the future of hobby electronics, so if you stick with it, you’ll probably end up in the world of surface-mount.
Vacuum tubes were not mentioned, because at this point, they are mainly of historical interest. But there’s something very special and beautiful about tubes, especially if you can enclose them in fancy cabinetwork. In the hands of a skilled craftsperson, tube amplifiers and radios become art objects.
I didn’t show you how to etch your own printed circuit boards. This is a task that appeals to only certain people, and the preparation for it requires you to make very neat drawings or use computer software for that purpose. If you happen to have those resources, you might want to do your own etching. It could be a first step toward mass-producing your own devices.
I didn’t cover static electricity at all. High-voltage sparks don’t have any practical applications, and they entail some safety issues—but they are stunningly impressive, and you can easily obtain the necessary information to build the equipment. Maybe you should try.
Other Controllers
If you want something more powerful, a BASIC Stamp is the logical next step after a PICAXE. the BASIC Stamp is so called because it originally looked like a postage stamp. The BASIC Stamp has a larger vocabulary of commands and a bigger range of add-on devices (including displays with graphical capability, and a little keyboard that is specifically designed for use with the controller). The BASIC Stamp is shown in Figure 5-149.
Figure 5-149. The BASIC Stamp controller consists of surface-mounted components on a platform that has pins spaced at 1/10-inch intervals, for insertion in a breadboard or perforated board. This component uses a version of BASIC that is similar to the programming language of the PICAXE, but has many more extensions. The BASIC Stamp is available for use with a wide range of peripheral devices, including many alphanumeric dot-matrix displays.
On the downside, you’ll find that everything associated with the BASIC Stamp is a bit more expensive than in the PICAXE world, and the download procedure isn’t quite as simple.
One of the more recent developments in the world of MCUs is the Arduino, which is both sophisticated and powerful. It does require programming in the C language. This language is a little more difficult to understand, and has only the vaguest similarity to the syntax that is used in the PICAXE and BASIC Stamp. On the other hand, because C dominates the larger world of computing, learning it might not be such a bad idea—and the Arduino offers some truly amazing capabilities. Because it is so popular, there are also many software tools, documentation, user forums, and many enthusatic hobbyists to help you. Two other Make: Books titles that I mentioned previously, Getting Started with Arduino and Making Things Talk, provide a great introduction.
In Closing
I believe that the purpose of an introductory book is to give you a taste of a wide range of possibilities, leaving you to decide for yourself what you want to explore next. Electronics is ideal for those of us who like to do things ourselves, because almost any application—from robotics, to radio-controlled aircraft, to telecommunications, to computing hardware—allows opportunities that we can explore at home, with limited resources.
As you delve deeper into the areas of electronics that interest you most, I trust you’ll have a satisfying learning experience. But most of all, I hope you have lots of fun along the way.
Appendix. Online Retail Sources and Manufacturers
This appendix contains URLs for companies mentioned as retail sources or manufacturers, along with the commonly used name of the source and the company name.
Colloquially used name
Actual corporate or company name
URL
3M
Minnesota Mining and Manufacturing Co.
http://solutions.3m.com/en_US/
Ace Hardware
Ace Hardware Corporation
http://www.acehardware.com
Adva
nced Micro Circuits
Advanced Micro Circuits Corp
http://www.advancedmicrocircuits.com
Akro-Mils
Myers Industries, Inc.
http://www.akro-mils.com
Alcoswitch
Division of Tyco Electronics Corporation
http://www.tycoelectronics.com/catalog/menu/en/18025
All Electronics
All Electronics Corporation
http://www.allelectronics.com
All Spectrum Electronics
All Spectrum Electronics
http://www.allspectrum.com
All-Battery.com
Tenergy Corporation
http://www.all-battery.com
Alpha potentiometers
Alpha Products Inc.
http://www.alphapotentiometers.net
ALPS pushbutton
ALPS Electric Co., Ltd.
http://www.alps.com
Amazon
Amazon.com, Inc.
http://www.amazon.com
Amprobe
Amprobe Test Tools
http://www.amprobe.com
Arduino
No corporate identity
http://www.arduino.cc
ArtCity
ArtCity
http://www.artcity.com
AutoZone
AutoZone, Inc.
http://www.autozone.com
Avago
Avago Technologies
http://www.avagotech.com
BASIC Stamp
Brand owned by Parallax, Inc.
http://www.parallax.com
BI Technologies
BI Technologies Corporation
http://www.bitechnologies.com
BK Precision
B&K Precision Corp.
http://www.bkprecision.com
Bussmann fuses
Cooper Bussman, Inc.
http://www.cooperbussmann.com
C&K switch
CoActive Technologies, Inc.
http://www.ck-components.com
Chicago lighting
CML Innovative Technologies
http://www.cml-it.com
CraftAmerica
Cardinal Enterprises
http://www.craftamerica.com
Darice
Darice Inc.
http://www.darice.com
DeWalt
DeWalt Industrial Tool Company
http://www.dewalt.com
Digi-Key
Digi-Key Corporation
http://www.digikey.com
Directed switches
Directed Electronics Inc.
http://www.directed.com
Doctronics
Doctronics Educational Publishing
http://www.doctronics.co.uk
eBay
eBay Inc.
http://www.ebay.com
Elenco
Elenco Electronics Inc.
http://www.elenco.com
Everlight
Everlight Electronic Co. Ltd.
http://www.everlight.com
Extech
Extech Instruments Corporation
http://www.extech.com
Fairchild
Fairchild Semiconductor Incorporated
http://www.fairchildsemi.com
FTM
FTM Incorporated
http://thefabricatorssource.com
Fujitsu
Fujitsu America, Inc.
http://www.fujitsu.com/us/
GB wire strippers
Gardner Bender Inc.
http://www.gardnerbender.com
Hobbylinc
Hobbylinc Hobbies
http://www.hobbylinc.com
Home Depot
Homer TLC, Inc.
http://www.homedepot.com
Ideal wire strippers
Ideal Industries Inc.
http://www.idealindustries.com
Jameco
Jameco Electronics
http://www.jameco.com
K&J Magnetics
K&J Magnetics Inc.
http://www.kjmagnetics.com
Kingbright
Kingbright Corporation
http://www.kingbrightusa.com
Kobiconn
No web page found; use mouser.com
KVM Tools
KVM Tools Inc.
http://www.kvmtools.com
Lowe’s hardware
LF, LLC
http://www.lowes.com
Lumex
Lumex Inc.
http://www.lumex.com
McMaster-Carr
McMaster-Carr Supply Company
http://www.mcmaster.com
Megahobby
Megahobby.com
http://www.megahobby.com
Meter Superstore
Division of SRS Market Solutions Inc.
http://www.metersuperstore.com
Michaels craft stores
Michaels Stores, Inc.
http://www.michaelscrafts.com
Mill-Max
Mill-Max Manufacturing Corp.
http://www.mill-max.com
Mitutoyo
Mitutoyo America Corporation
http://www.mitutoyo.com
Motorola
Motorola, Inc.
http://www.motorola.com/us
Mouser electronics
Mouser Electronics, Inc.
http://www.mouser.com
Mueller alligator clip
Mueller Electric Company
http://www.muellerelectric.com
Newark
Subsidiary of Premier Farnell plc
http://www.newark.com
NKK switches
Nihon Kaiheiki Industry Co. Ltd.
http://www.nkkswitches.com
NXP semiconductors
NXP Semiconductors
http://www.nxp.com
Omron
Omron Corporation
Make: Electronics Page 43