Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Electronics Projects: How to Connect a Push Button to a BASIC Stamp

If you want the BASIC Stamp to react to the status of an external electronic circuit, connect a pushbutton to an I/O pin. Then, you can add commands to your PBASIC program to detect whether the pushbutton is pressed. There are two ways to connect a pushbutton to a BASIC Stamp I/O pin:

  • Active-high: This connection places +5 V on the I/O pin when the pushbutton is pressed. When the button is released, the I/O pin sees 0 V.

  • Active-low: This connection sees +5 V when the pushbutton is not pressed. When you press the pushbutton, the +5 V is removed, and the I/O pin sees no voltage.

    image0.jpg

In the active-high circuit, the I/O pin is connected to ground through R1 and R2 when the pushbutton isn't pressed. Thus, the voltage at the I/O pin is 0. When the pushbutton is pressed, the I/O pin is connected to Vdd (+5 V) through R1, causing the I/O pin to see +5 V. As a result, the I/O pin is LOW when the button isn't pressed and HIGH when the button is pressed.

In the active-low circuit, the I/O pin is connected to Vdd (+5 V) through R1 and R2, causing the I/O pin to go HIGH. But when the button is pressed, the current from Vdd is shorted to ground through R2, causing the voltage at the I/O pin to drop to zero. Thus, the I/O pin is HIGH when the button isn't pressed and LOW when the button is pressed.

Note that in both circuits, R1 is connected directly to the I/O pin to prevent excessive current flow when the switch is pressed. Without this resistor, the pin would be connected directly to Vdd (+5 V) or Vss (ground) when the button is pressed, which could damage the BASIC Stamp.

In an active-high circuit, R2 is called a pull-down resistor because it pulls the current from the I/O pin down to zero when the pushbutton isn't depressed. In an active-low circuit, R2 is called a pull-up resistor because it pulls the voltage at the I/O pin up to Vdd (+5 V) when the pushbutton isn't depressed.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.