NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Sensors, Actuators, and Robotics » Push Button

July 19, 2011
by Pr0ject
Pr0ject's Avatar

Hello, my nerdkits came with a push button, but the only problem is I dont know how to install and use it, can someone give me directions?

July 19, 2011
by bretm
bretm's Avatar

If I recall correctly it has 3 pins coming out of it. Insert it into the breadboard so that each pin is in a separately-numbered row. The pins are rather thick so you might have to give it some pressure.

The center pin will connect to one or the other of the two other pins. Which one depends on whether the button is pressed or not.

Connect the center pin row to the ground rail and one of the other rows to a digital input pin row of the MCU. The library has some code that shows how to read the state of the input pin.

I prefer this type of button. It takes less room and fits into the breadboard more easily.

July 19, 2011
by bretm
bretm's Avatar

The Traffic Light project page has a picture showing the installed button:

push button

July 19, 2011
by Pr0ject
Pr0ject's Avatar

Thank you so much! This is going to help me a lot :D

July 19, 2011
by bretm
bretm's Avatar

Depending on what you do with the button, you might encounter a problem called switch bouncing. When you press the button it will actually make and break the electrical contact many times in short succession until it settles down. The MCU can observe the state of the switch fast enough that it will see what looks like multiple rapid button presses. You may have to account for that, depending on what you're doing.

This three-connection switch (Double Throw type) is easier to debounce than the other type of switch I linked (Single Throw type) if you're willing to use two input pins instead of one. Connect one side of the switch to one pin and the other side to a second pin. When you see the switch close on one side, just ignore any other changes until you see it close on the opposite side. Then ignore changes on that side until it switches back to the other side again. Only one side or the other will bounce at a time.

Post a Reply

Please log in to post a reply.

Did you know that the microcontroller's crystal oscillator can be used to keep accurate time? Learn more...