Big Dome Push Button & LinkIt Basics

About: I am a queer, transgender, nonbinary, and mixed-race picture book writer/illustrator. As a young person, I didn’t have the words to explain the big feelings I had about my identity and relationships. It is s...

When I first got Sparkfun's big dome push button in the mail, I was a little confused. Why were there 5 terminals on a button and no data sheet? Never fear! I've drawn up a quick guide. The two terminals on the side are for the LED. The terminal on the top (if you are holding the button upside down, as in the Illustration above) is the common. The two terminals sticking outwards are for push to make and push to break. You'll likely only need to choose one of those. Using the LED is totally optional and if you don't want your LED controlled by a microcontroller, you could also just hook up a battery to it if you want it on constantly.

Wiring guide:

Arduino has a pretty good push button guide: https://www.arduino.cc/en/Tutorial/DigitalReadSeri...

Essentially, you need to connect one terminal to power and another terminal to a digital pin (I'm using 2). To the second terminal, you also want to connect through a pull down resistor to ground. See Illustration or try it out on 123d Circuits.

In this example, the only thing that happens is that "hello" is printed to the serial monitor followed by 1 if the button is pressed, and "0" if it isn't.

Simple code version:

int pushButton = 2;

// the setup routine runs once when you press reset:

void setup() {

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

// make the pushbutton's pin an input:

pinMode(pushButton, INPUT);

}

// the loop routine runs over and over again forever:

void loop() {

// read the input pin:

int buttonState = digitalRead(pushButton);

Serial.println("hello");

// print out the state of the button:

Serial.println(buttonState); // 1 is on (pushed), 0 is off

delay(10);

// delay in between reads for stability (1000 = 1 second).

}

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Understanding State Changes

You'll notice that in the previous example, as long as the button is pressed, the serial monitor will display 1 repeatedly. And when the button is not pressed, the serial monitor will display 0 repeatedly. What if we are only interested in the state change--that is knowing when the button goes from unpressed to pressed and vice versa?

See: https://www.arduino.cc/en/Tutorial/StateChangeDetection

In this example, the code counts how many presses and only prints to the serial monitor when it detects a new press.

Step 2: What's Next?

Now that we have a push button that can either detect when its state changes or constantly monitor its state, let's make something interesting that uses that information. Maybe it will be a travelling button that measures where and how often a big red button gets pressed. Maybe this button will be a dinner bell to tell everyone that food is ready. Maybe this big red button will do something else.

What would you like to see?

Be the First to Share

    Recommendations

    • Assistive Tech Contest

      Assistive Tech Contest
    • Reuse Contest

      Reuse Contest
    • Made with Math Contest

      Made with Math Contest

    Discussions