There are basically two ways to add simple button input for this project. We could just add a button to each digital pin, but that would limit the number of buttons we could use. This time around we will use resistors along side of our buttons and read the analog value based on what button was pressed. This works by adding one resistor to each button, but also setting the resistors up in series. When nothing is pressed, all of the resistors are used and we get a low number value when the analog pin is read. When we press a button, it shorts out the resistor string and we get another value when the analog pin is read. The higher the button is on the chain, the lower the analog value is. Ultimately, this means that we can add as many buttons as we want and only use up one PIN to do it.

We will now connect all of the components to match what is shown below. There should be just enough room to fit 3 of the colored push buttons and one of the 6MM buttons side by side.

  1. Connect one of the GND pins to the - side of the breadboard.
  2. The 3V pin should connect with the + side of the breadboard.
  3. Connect one side of each button to it neighbouring button.
  4. The last button will connect to the A pin on the HUZZAH.
  5. Now add one resister connecting GND to the A pin.
  6. Add the remaining resisters to the other side of each button in series with the last two connecting with the 3V pin.

This can be powered through the FTDI cable, but you may want to add a battery or other power supply by connecting it to the GND and VBat pins.

Now it's time to code.

This guide was first published on Oct 11, 2015. It was last updated on Mar 08, 2024.

This page (Buttons Wiring) was last updated on Sep 30, 2015.

Text editor powered by tinymce.