The BASIC Stamp is a small, single-board microcontroller developed by Parallax, Inc. that runs a customized version of the BASIC programming language called PBASIC. It serves as an excellent starting point for learning microcontroller basics because it simplifies both hardware wiring and software coding. Core Components of a Microcontroller
Every microcontroller, including the BASIC Stamp, relies on three core areas to function: Processor (CPU): Executes the program instructions.
Memory: Stores the code (EEPROM) and temporary variables (RAM).
I/O Pins: Input/Output pins connect to sensors, lights, and motors. Code Analysis: The “Hello World” of Hardware
Below is a standard PBASIC program used to blink an LED connected to Output Pin 14.
’ {\(STAMP BS2} ' {\)PBASIC 2.5} Main: HIGH 14 PAUSE 500 LOW 14 PAUSE 500 GOTO Main Use code with caution. Line-by-Line Breakdown
’ {\(STAMP BS2}</code></strong>: Compiler directive. Tells the software you are using the BASIC Stamp 2 hardware.</p> <p><strong><code>' {\)PBASIC 2.5}: Language directive. Specifies the version of the PBASIC language syntax being used.
Main:: A label. It marks a specific location in the code so the program can jump back to it later.
HIGH 14: Turns on Pin 14. It sends 5 volts (logic high) to the pin, lighting up the connected LED.
PAUSE 500: Freezes the program for 500 milliseconds (0.5 seconds). The LED stays on during this time.
LOW 14: Turns off Pin 14. It drops the voltage to 0 volts (logic low), turning off the LED.
PAUSE 500: Holds the program for another 0.5 seconds. The LED stays off during this time.
GOTO Main: An infinite loop. It forces the program to jump back to the Main: label and repeat forever. How the Hardware Interacts
When this code executes, the microcontroller continuously cycles its physical pin between an active source of electricity and a ground state.
Inputs vs. Outputs: In this code, Pin 14 is automatically configured as an output because it is given a command (HIGH/LOW) to send electricity out.
Current Limiting: In a physical circuit, a resistor must be placed between Pin 14 and the LED to prevent too much electricity from burning out the microcontroller or the light. To help apply this to your project, tell me:
Do you have a specific BASIC Stamp model (like the BS2) or are you studying theory?
Leave a Reply