2

I am getting back into doing some hardware stuff after a fairly long time away and am having a hard time getting back into it. I have a Teensy 2.0 and am trying to run a basic sketch that when a button is pressed will output 0, but my button is always High. I think that I miswired something but my breadboard looks like all the tutorials so I'm just confused as to what is going on and would appreciate any help.

const int pinBtnUp = 0;
const int pinLEDOutput = 11;

void setup()
{
  Serial.begin(38400);

  //Setup the pin modes.
  pinMode( pinLEDOutput, OUTPUT );
  //Special for the Teensy is the INPUT_PULLUP
  //It enables a pullup resitor on the pin.
  pinMode( pinBtnUp, INPUT_PULLUP );

}

void loop()
{
  Serial.println(digitalRead(pinBtnUp));  
}

Breadboard

1
  • Am I correct in assuming those side rails are all connected? Where is the schematic for this? – NoBugs Aug 31 '15 at 1:05
3

You should post a higher quality version next time.

Wiring:

First of all, the button looks like it's not all the way in. Fix that first.

Also, from your picture, it looks like the green wire isn't in the right row:

I can't tell for sure. Also, like mentioned before, you to put the button over the gap between the two sides of the breadboard.

Also, you have a pullup resistor in your circuit and you enable it on the Arduino. And your physical pullup resistor isn't connected to your signal line. And you short your signal line to ground. All of this is incorrect wiring...

If utilizing the internal pullup resistor (like you are in your code), all you should need to do for a circuit is like this:

Just be sure to connect the 5V rail to 5V and the green wire to your digital pin.

Code:

That's all fine. When doing logic with a button, be sure to debounce it.

2

You would need to place your button over the "valley" in the centre of the breadboard, separating teh top 2 and bottom 2 legs of the button.

Currently the wire connecting the button to Pin 0 on your teensy is also connected to your pullup resistor on the breadboard, as it is in the same row.

To help troubleshoot this kind of thing I always find a digital multimeter very useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.