This demo shows reading the state of a push-button from WipperSnapper. But the same kind of control can be used for reading switches, break beam sensors, and other digital sensors.
You can configure a board running WipperSnapper to read data from standard input buttons, switches, or digital sensors, and send the value to Adafruit IO.
From Adafruit IO, you will configure one of the pushbuttons on your board as a push button component. Then, when the button is pressed (or released), a value will be published to Adafruit IO.
Button Location
This example uses the board's built-in push-button and internal pull-up resistor instead of wiring a push-button up.
There are two possible locations for the user button (BOOT/DFU) on the Metro S2 board, depending on the revision (A, B, or C in a circle).
The original layout (Revision A) is labelled Beta on the printed silkscreen label and featured in the majority of images in this guide. The user button is labelled DFU and located in the middle of the board, check the pinouts page for the button location image.
If you order one today then you'll get the revision C, with the user button labelled BOOT and located on the opposite side to the USB and reset button.
Create a Push-button Component on Adafruit IO
On the device page, click the New Component (or "+") button to open the component picker.
Search for the component name by entering push
into the text box on the component picker, the list of components should update as soon as you stop typing.
Since WipperSnapper supports such a large number of components, you can use filtering. Try searching for various keywords, like:
- component names:
aht20
,servo
,buzzer
,button
,potentiometer
, etc - sensor types:
light
,temperature
,pressure
,humidity
, etc - interface:
i2c
,uart
,ds18x20
,pin
, etc (also I2C addresses e.g.0x44
) - vendor:
Adafruit
,ASAIR
,Infineon
,Bosch
,Honeywell
,Sensirion
, etc
There are also added product and documentation links for every component. Follow the links beneath the component descriptions to be taken to the appropriate product page or Learn Guide.
Select the Push Button from the list of results to go to the component configuration page.
There will be a back button if you select the wrong component, and you can use the Edit component icon (⚙️) on the device page to update the component configuration in the future.
The "Create Push Button Component" form presents you with options for configuring the push button.
Start by selecting the board's pin connected to the push button.
Most of the boards have a pin with Button in the name so IO can magically select the pin for you!
The Return Interval dictates how frequently the value of the push-button will be sent from the board to Adafruit IO.
For this example, you will configure the push button's value to be only sent when the value changes (i.e. when it's either pressed or depressed).
Finally, check the Specify Pin Pull Direction checkbox and select the pull direction.
Make sure the form's settings look like the following screenshot. Then, click Create Component.
Adafruit IO sends a command to your WipperSnapper board, telling it to configure the GPIO pin you selected to behave as a digital input pin and to enable it to pull up the internal resistor.
Your board's page should also show the new push-button component.
Push the button on your board to change the value of the push-button component on Adafruit IO.
Text editor powered by tinymce.