| 1. | Introduction | 1 |
| Requirements | 2 |
| Microcontrollers | 2 |
| Programming Fundamentals | 4 |
| Programming Languages | 5 |
| The BASIC Programming Language | 7 |
| 2. | Introducing the BASIC Stamps | 11 |
| What is a BASIC Stamp? | 12 |
| Stamp Hardware: Overview | 12 |
| Stamp Hardware: Detailed Tour | 13 |
| PBASIC Interpreter Chip (U1) | 13 |
| Program Memory (U2) | 17 |
| Programming Connection | 17 |
| Power Supply (U4) | 17 |
| Reset Circuit (U3) | 18 |
| Special Features of the BS2-SX and BS2-E | 18 |
| Choosing a Stamp to Start On | 18 |
| The Future of the Stamps | 19 |
| Stamp-Specific and Stamp-Friendly Kits and Accessories | 19 |
| Robots | 19 |
| Stamp Peripherals | 22 |
| 3. | Electronic Foundations | 25 |
| Electricity | 26 |
| Batteries and Circuits | 27 |
| Resistance | 27 |
| Electrical Properties, Measurements, and Units | 28 |
| Ohm's Law: a Quick Preview | 28 |
| Electronic Components and Symbols | 30 |
| Batteries and Power Supplies | 30 |
| Resistors | 30 |
| Potentiometers ("Pots") | 31 |
| Capacitors | 31 |
| Diodes and LEDs | 33 |
| Transistors | 33 |
| Integrated Circuits | 34 |
| Other Components | 35 |
| Combining Symbols into Schematics | 36 |
| 4. | Building Electronic Circuits | 39 |
| Plug-in Prototyping Boards | 40 |
| Crimp Connectors | 42 |
| Wire Wrapping | 43 |
| Soldering | 44 |
| Printed Circuit Boards | 47 |
| Tools and Test Equipment | 49 |
| Summary of Construction Techniques | 50 |
| 5. | Getting Started with Stamps | 57 |
| What You'll Need | 52 |
| Connecting the Stamp Hardware | 52 |
| Installing and Starting the Stamp Software | 53 |
| Configuring the Stamp Software | 54 |
| Initial Checkout: Hello World | 56 |
| Installing the Program Examples | 58 |
| Understanding the Program Process | 59 |
| Where Do I Go from Here? | 59 |
| 6. | BASIC Stamp Boot Camp, Part 1 | 61 |
| Variables: Storage Spaces for Numbers | 62 |
| Variables Have Fixed Sizes | 63 |
| Name Those Variables | 64 |
| Constants are Unchanging Values | 65 |
| Summary | 66 |
| Labels, Gotos and Loops | 66 |
| For...Next, Another Kind of Loop | 67 |
| Getting in Step | 68 |
| Making Decisions with If...Then | 69 |
| Combining If...Then Conditions | 70 |
| Multiple Possibilities with Branch | 71 |
| Looking Up Values from a List | 73 |
| Another Look at a List: Lookdown | 73 |
| Create Your Own Instructions with Gosub | 74 |
| Passing Data to Subroutines | 75 |
| At Ease! End of Boot Camp Part 1 | 76 |
| 7. | BASIC Stamp Boot Camp, Part 2 | 77 |
| Seeing the World through an Input | 78 |
| Where Does Input Come From? | 79 |
| Changing the World through an Output | 79 |
| Deeper Meanings of "Input" and "Output" | 80 |
| Output Bit | 80 |
| Direction Bit | 81 |
| Input Bit | 81 |
| Summing up the I/O Trio | 82 |
| Variations on an LED Blinker | 82 |
| Controlling the LED Blinker | 83 |
| Final Example: Dial-controlled Timer | 84 |
| Comments | 84 |
| Formatting | 87 |
| The Timer Programs | 88 |
| Boot Camp Graduation | 89 |
| 8. | Magic Message Machine | 91 |
| Persistence of Vision (POV) | 92 |
| Putting POV to Work | 92 |
| A Different Spin on POV | 93 |
| Initial Experiments with POV | 93 |
| Displaying a Text Message | 95 |
| Modifications and Photography | 97 |
| Parts List | 99 |
| 9. | Intelligent Traffic Signal Simulation: BS1 | 101 |
| Traffic School | 102 |
| Stoplight Circuit | 103 |
| Construction and Modifications | 105 |
| Parts List | 105 |
| 10. | Robotic Bug with Whisker Sensors: BS1 | 107 |
| Motors, Ready-to-roll | 108 |
| Modifying Servos to Drive Wheels | 109 |
| Building and Programming the Robot | 111 |
| Adding Collision-detection Sensors | 112 |
| Modifications and Improvements | 115 |
| Parts List | 118 |
| 11. | Time/Temperature Display: BS1 | 119 |
| Keeping Time | 120 |
| Measuring Temperature | 121 |
| ADC0831 Analog-to-digital Converter | 122 |
| 2x16 Serial LCD Module | 124 |
| All Together Now | 126 |
| Parts List | 129 |
| 12. | Data-Logging Thermometer: BS2 | 131 |
| Getting Peripherals on the Bus | 132 |
| Different Bus Widths | 132 |
| Programming for the Serial Bus | 133 |
| A Synchronous-serial Thermometer | 140 |
| BS2-based Temperature Logger | 140 |
| Summary | 148 |
| Parts List | 148 |
| 13. | Worldwide Remote Control with C2TERM: BS2 | 151 |
| Asynchronous Serial Communication | 152 |
| Serial Timing and Framing | 152 |
| Serial Parameters | 153 |
| Bit Rate (Baud) | 153 |
| Parity | 153 |
| Data Bits | 154 |
| Stop Bits | 154 |
| A Serial Frame | 155 |
| RS-232 Serial Signals | 155 |
| Serial Communication by Modem | 157 |
| X-10 Appliance Control | 158 |
| C2TERM | 161 |
| Initial X-10 checkout | 161 |
| Modem Checkout | 161 |
| Display and Button Checkout | 163 |
| Complete C2TERM Application | 166 |
| Going Further | 172 |
| Parts List | 173 |
| 14. | Short-Range Sonar: BS2 | 175 |
| Sonar Principles | 176 |
| Frequency and Wavelength | 176 |
| The Sonar Circuitry | 177 |
| Construction Notes | 181 |
| The Sonar Program | 181 |
| Just for Fun--the "Sonamin" | 185 |
| Going Further | 185 |
| Parts List | 186 |
| Other Components | 187 |
| 15. | Network Terminal with Keypad and Display: BS2 | 189 |
| Alphanumeric LCD Modules | 190 |
| Cursor Positioning | 193 |
| Keypad Interface | 194 |
| Stand-alone LCD/keypad demo | 195 |
| RS-485 Networking | 202 |
| RS-485 Interface | 203 |
| Limitations of the Demo Application | 204 |
| The Network Terminal | 204 |
| Parts List | 215 |
| 16. | Using the Powerful BS2-SX | 217 |
| SX-Powered Stamp | 218 |
| Speed: More Than Just Fast | 218 |
| Scratchpad Memory: Flexible Temporary Storage | 221 |
| Multiple Programs: Multiple Personalities | 222 |
| Practical Examples of BS2-SX Programming | 223 |
| Example 1 | Moving Between Programs | 223 |
| Example 2 | Variables and Scratchpad RAM | 224 |
| Example 3 | Navigating Inside Programs | 225 |
| Example 4 | Backing Up Your Variables | 228 |
| 17. | Charge-Transfer Capacitance Sensing (BS2-SX) | 231 |
| Measuring Capacitance | 232 |
| The Change-Transfer Technique | 232 |
| Implementing Charge Transfer with the BS2-SX | 233 |
| Charge-Transfer Mechanics | 235 |
| Calibration and Interpolation | 235 |
| Using the Charge-Transfer Project | 243 |
| Other Applications of Charge Transfer | 244 |
| Appendices | |
| A. | BASIC Stamp Quick Reference Guides | 245 |
| BASIC Stamp 1 Language Reference | 246 |
| Program Memory (EEPROM) | 246 |
| Data Memory (RAM) | 247 |
| Input/Output (I/O) | 248 |
| Math and Logic (Let) | 248 |
| Instruction Summary | 248 |
| BASIC Stamp 2 Language Reference | 255 |
| Program Memory (EEPROM) | 255 |
| Data Memory (RAM) | 256 |
| Input/Output (I/O) | 257 |
| Math and Logic | 258 |
| Instruction Summary | 259 |
| Numeric Conversion Options for Serin | 265 |
| String Collection and Sequence Matching Options for Serin | 265 |
| Options for Serout | 265 |
| BASIC Stamp 2-SX and -E Language Reference | 268 |
| Program Memory (EEPROM) | 268 |
| Data Memory (RAM) | 268 |
| Scratchpad Memory (RAM) | 268 |
| Input/Output (I/O) | 269 |
| Math and Logic | 269 |
| Instruction Summary | 269 |
| Numeric Conversion Options for Serin | 275 |
| String Collection and Sequence Matching Options for Serin | 275 |
| Options for Serout | 276 |
| B. | Numbering Systems, Integer Math, and Boolean Logic | 279 |
| Numbering Systems | 280 |
| Digits, Weights, and Significance | 282 |
| Conversions | 283 |
| Numbers as Text and Text as Numbers | 283 |
| Math with Fixed-size Integers | 284 |
| Negative Numbers | 288 |
| Boolean Logic | 290 |
| So what? | 291 |
| Summary | 292 |
| C. | Electronic Calculations and Stamp-Related Circuits | 293 |
| Ohm's Law calculations | 294 |
| Resistances in Series and Parallel | 294 |
| Resistances in Series | 294 |
| Resistances in Parallel | 295 |
| Rules of Thumb and Shortcuts | 295 |
| Calculations with Rtotal | 295 |
| Circuits with Resistors in Series and Parallel | 296 |
| Series Resistors as a Voltage Divider | 296 |
| Potentiometers as Adjustable Voltage Dividers | 297 |
| Digital Switch Input | 298 |
| Switches in the Real World | 299 |
| Why are Pullups Preferred? | 299 |
| LED Output | 300 |
| Switching Bigger Loads with Transistors | 300 |
| Calculating Resistor-capacitor (RC) Timing | 301 |
| Using an External Voltage Regulator | 304 |
| Building an Efficient Switching Power Supply | 305 |
| Why Bother? | 306 |
| D. | Bug-Hunting Guide | 309 |
| E. | Sources for Electronic Components | 313 |
| Component Sources | 314 |
| F. | Suggested Reading | 317 |
| G. | Glossary | 321 |
| Index | 331 |