Chapter 3

Discovering More PBASIC Programming Tricks

In This Chapter

arrow Connecting pushbuttons

arrow Generating random numbers

arrow Using a potentiometer as input

arrow Creating subroutines with the GOSUB command

In this chapter, we describe some more PBASIC programming techniques, to add to the fundamental ones we introduce in Chapter 2 of this minibook. These tips are sure to become invaluable in your BASIC Stamp projects. Specifically, you discover handling input data in the form of pushbuttons, generating random numbers (that make your programs more interesting by adding a degree of randomness), reading the value of a potentiometer and using the GOSUB command to organise your program into subroutines.

Pushing Buttons with a BASIC Stamp

In Chapter 2 of this minibook, we discuss connecting a light-emitting diode (LED) to a BASIC Stamp I/O pin and turning the LED on or off by using the HIGH and LOW commands in a PBASIC program. Those commands are designed to use BASIC Stamp I/O pins as output pins by setting the status of an I/O pin to high or low so that external circuitry (such as an LED) can react ...

Get Electronics All-in-One For Dummies, UK Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.