Chap. 3 Digital Input - Pushbuttons (Turn the LED off with a Pushbutton)

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.

Comments

  • Sounds like the circuit and code is working, but somewhere in the circuit or code the polarity gets reversed. Could be one of 3 problems. The input circuit could be miswired, the output circuit could be miswired, or the code could be wrong.

    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.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • From what you describe, I believe you have you have the diode inserted backwards, the cathode (-) lead and the anode (+) lead are reversed.
  • kwinn wrote: »
    ....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.

  • JGoodard wrote: »
    kwinn wrote: »
    ....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.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • JGoodard,

    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".
  • kwinn wrote: »
    ....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.

    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.
  • Genetix wrote: »
    JGoodard,

    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".

    Forgive my ignorance, I am new to this, what's the difference between a series and a parallel?
  • JGoodard,

    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.
  • Series elements see the same current.
    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 ]
Sign In or Register to comment.