5 Simple Basic Stamp Sample Projects for Beginners

Basic Stamp Sample: Quick Start GuideThe Basic Stamp is a simple, beginner-friendly microcontroller platform originally developed by Parallax, Inc. It’s designed to make learning embedded programming and electronics approachable—particularly for educators, hobbyists, and students. This guide walks you through what a Basic Stamp is, what you need to get started, a step‑by‑step sample project, essential commands and code examples, tips for debugging, and ideas for next projects.


What is the Basic Stamp?

The Basic Stamp is a microcontroller module that runs a form of BASIC (PBASIC). It combines a microcontroller, EEPROM with a BASIC interpreter, and standard I/O pins. Programs are written in PBASIC on a host computer and then downloaded to the Stamp, where they run stand‑alone.

Key strengths: simplicity, broad educational use, lots of example projects and community resources.


What you need to get started

  • A Basic Stamp module (e.g., Basic Stamp 2 or BS2p)
  • A programming cable (serial or USB-to-serial adapter depending on your PC and Stamp model)
  • Power supply (typically 5V regulated, check your module)
  • Breadboard and jumper wires
  • A few basic electronic components: LEDs, resistors (220–470 Ω), pushbuttons, and a piezo buzzer or small DC motor if desired
  • The PBASIC Editor (Parallax’s software) or a compatible text editor and a utility to send code to the Stamp

Basic Stamp I/O and pins

Basic Stamps expose multiple I/O pins labeled like P0, P1, P2, etc. Each pin can be configured as input or output in software. Some models also offer serial and PWM‑style support via software.

Common pin operations:

  • Outputs: drive LEDs, relays, transistors, small motors (with driver)
  • Inputs: read pushbuttons, sensors (use pull‑down or pull‑up resistors as needed)

Always check voltage/current limits; use transistors or drivers for loads drawing more than a few milliamps.


PBASIC essentials

PBASIC is the BASIC dialect used on the Stamp. It’s simple and procedural. Key concepts:

  • Directives: e.g., DEBUG to send text to the serial terminal, TRIS for pin direction on some models.
  • Labels and GOTO: simple flow control using labels.
  • Pulses and timing: PULSOUT, PAUSE for timing, and FREQOUT for generating tones.
  • Reading inputs: USING and LOOKUP can be used in advanced routines; simple input reads through IF statements and bit testing.
  • Variables: numeric and string handling are basic but sufficient for many projects.

Example of a minimal PBASIC program that blinks an LED on P0:

' {$STAMP BS2} ' Blink example LED    CON 0 DO   HIGH LED   PAUSE 500   LOW LED   PAUSE 500 LOOP 

Step-by-step sample project: Blinking LED with pushbutton control

Goal: Blink an LED normally; when a pushbutton is pressed, change blink speed.

Hardware:

  • Basic Stamp (BS2)
  • LED + 330 Ω resistor connected to P0 → LED → resistor → GND
  • Pushbutton between P1 and +5V, with P1 pulled down internally or with a 10 kΩ resistor to GND

PBASIC code:

' {$STAMP BS2} ' Blink with button speed control LED     CON 0 BTN     CON 1 FAST    CON 100 SLOW    CON 500 DO   IF IN(BTN) = 1 THEN     PAUSE FAST   ELSE     PAUSE SLOW   ENDIF   HIGH LED   PAUSE 50   LOW LED LOOP 

Notes:

  • IN(pin) reads the logic level on a pin (1 = high).
  • Adjust FAST and SLOW to change timing.
  • Debounce button in software if false triggers occur (see troubleshooting below).

Debugging tips

  • No response from Stamp: verify power (5V), cable connections, and correct COM port settings.
  • Program won’t download: ensure correct {$STAMP} directive matches your module and that the PBASIC editor/utility targets the right COM port and baud rate.
  • Button bounce: implement debounce by waiting 10–50 ms after a state change and re‑checking the input.
  • LED not lighting: check resistor value and LED polarity; measure pin voltage with a multimeter.
  • Motor or buzzer drawing too much current: use a transistor or MOSFET driver and add a flyback diode for inductive loads.

Example software debounce snippet:

IF IN(BTN) = 1 THEN   PAUSE 20   IF IN(BTN) = 1 THEN     ' confirmed press   ENDIF ENDIF 

Helpful PBASIC commands (quick reference)

  • HIGH pin — set pin high
  • LOW pin — set pin low
  • PAUSE ms — delay in milliseconds
  • PULSOUT pin, pulsewidth — generate a timed pulse
  • FREQOUT pin, duration, frequency — generate a tone
  • IN(pin) — read digital input
  • GOSUB/RETURN — call subroutines
  • DEBUG — send text/data to serial terminal for debugging

Safety and best practices

  • Use current‑limiting resistors for LEDs.
  • Don’t exceed I/O pin current limits; use drivers or transistors for larger loads.
  • Decouple power with a 0.1 µF capacitor near the module to reduce noise.
  • When experimenting with motors or inductive loads, add diodes and separate power supplies if necessary.

Project ideas to try next

  • LED chaser (running lights) using an array of LEDs.
  • Temperature monitor with a TMP36 sensor and display on an LCD.
  • Simple line follower robot with two basic Stamp‑driven motors and photoresistors.
  • Door alarm using a magnetic reed switch and piezo buzzer.
  • Serial-controlled LED dashboard using DEBUG and a terminal program.

Conclusion

The Basic Stamp is an excellent entry point into microcontrollers and embedded systems because of its readable PBASIC language and straightforward I/O. Start with simple projects like the blinking LED above, learn PBASIC commands, practice wiring safely, and progressively take on sensor and actuator projects. The core skill is translating a real‑world requirement into pin reads/writes and timing logic—once you’ve done that a few times, more complex projects become straightforward.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *