Chap. 3 Digital Input - Pushbuttons (Turn the LED off with a Pushbutton)
JGoodard
Posts: 6
in BASIC Stamp
From chap. 3 of "What's a Microcontroller?", 'Your Turn-Turn the LED off with a Pushbutton' (p.64) -
"Figure 3-5 shows a circuit that will cause the LED to behave differently. When the button is not pressed, the LED stays on; when the button is pressed, the LED turns off."
Assembling the circuit exactly as shown in figure 3-5 (p.65) I obtain the opposite result on my board, the LED turns ON when the pushbutton is pressed. The LED is off when the pushbutton is not pressed.
Any troubleshooting suggestions?
Thanks.
"Figure 3-5 shows a circuit that will cause the LED to behave differently. When the button is not pressed, the LED stays on; when the button is pressed, the LED turns off."
Assembling the circuit exactly as shown in figure 3-5 (p.65) I obtain the opposite result on my board, the LED turns ON when the pushbutton is pressed. The LED is off when the pushbutton is not pressed.
Any troubleshooting suggestions?
Thanks.
Comments
Measure the voltage on the input pin when the button is pressed, and when it is released. Then look at the code to see what happens to the output when the input is high, then low.
Hi,
How do I measure the voltage on the input pin for the pushbutton? For this particular exercise, there is no code, as this a test circuit. (pp. 64-65 of "What's a Microcontroller" located here: https://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf)
I purchased this Digital Multimeter DVM810 thinking I may need it. Will arrive Wed.
Sorry, I thought you were using the micro to control the led.
If you wired the circuits exactly like figure 3-4 and then 3-5 it is most likely that you have a pushbutton that has one side that is open (pins 3-4) and the other side (pins 1-2) that is closed when the button is not pushed. Pushing the button reverses the open/closed side.
Double-check your switch wiring because you have the switch and LED wired in series instead of parallel.
Wired in series power must first go through the switch before it can get to the LED.
The way it should be wired, power will go through the LED but when the switch is pressed, power will go through the switch.
The switch has a lot less resistance than the LED circuit and current will always take "the path of LEAST resistance".
I found the source of the problem, the pushbutton pins were not inserted deep enough into the breadboard. It's difficult to determine with a part as small as this.
Forgive my ignorance, I am new to this, what's the difference between a series and a parallel?
I am glad that you found the problem.
Series means that the parts are wired one after another in a chain such as in Christmas lights were if one dies all the others passed it don't light up.
Parallel means that the parts are wired side by side such as when you go to checkout at a store and can choose which register to go to.
Parallel elements see the same voltage difference.
Anything in series with a switch that's off can get no current
Anything in paralllel with a switch that's on can get no voltage....
[ all assuming switches are perfect ]