Button & Switch Wireling Tutorial

This tutorial covers how to read basic inputs from Wirelings that utilize the analog line. This includes the Small Button Wireling, Large Button Wireling, and Switch Wireling.
Large Button Technical Details
FMS8HSMA Specs
- Height 7mm
TinyDuino Power Requirements
- Voltage: 3.0V - 5.5V
Pins Used
- A5/SCL - I²C Serial Clock line
- A4/SDA - I²C Serial Data line
Dimensions
- 10mm x 10mm (.394 inches x .394 inches)
- Max Height (from the lower bottom of Wireling to upper top Large Button): 10.3mm (0.41 inches)
- Weight: 1 gram (.04 ounces)
Notes
- You can also use this shield without the TinyDuino – modifying the connecting cable by removing the opposite connector and stripping/tinning the wires, you can solder the connector cable to any other microcontroller board of your choice!
Small Button Technical Details
ALPS SKTHBAE010 Switch Specs
- Height 2.5mm
- Operating Force: 3N
- Travel 0.12mm
TinyDuino Power Requirements
- Voltage: 3.0V - 5.5V
- Current: 10µA
Pins Used
- A5/SCL - I²C Serial Clock line
- A4/SDA - I²C Serial Data line
Dimensions
- 10mm x 10mm (.394 inches x .394 inches)
- Max Height (from the lower bottom of Wireling to upper top WirelingConnector): 3.70mm (0.15 inches)
- Weight: 1 gram (.04 ounces)
Switch Technical Details
Specs
- Cover: Stainless Steel
- Mechanical Lifecycle: 10,000 cycles
TinyDuino Power Requirements
- Voltage: 3.0V - 5.5V
Pins Used
- A5/SCL - I²C Serial Clock line
- A4/SDA - I²C Serial Data line
Dimensions
- 10mm x 10mm (.394 inches x .394 inches)
- Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
- Weight: 1 gram (.04 ounces)
Notes
- You can also use these Wirelings without the TinyDuino – modifying the connecting cable by removing the opposite connector and stripping/tinning the wires, you can solder the connector cable to any other microcontroller board of your choice!
Materials
To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable
There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.
Processor | Adapter |
---|---|
*TinyDuino and USB TinyShield | Wireling Adapter TinyShield |
*TinyZero | Wireling Adapter TinyShield |
*TinyScreen+ | Wireling Adapter TinyShield |
WirelingZero | N/A |
*RobotZero | N/A |
Arduino | Wireling Arduino Shield |
Raspberry Pi | Wireling Pi Hat |
* These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.
In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).
The table below lists which Wirelings can be utilized with the following code.
Wireling Selection |
---|
Hardware Assembly
Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch by editing the Analog pin noted in the program.)
NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

Software Setup
If you haven't already downloaded it, make sure you have the Wireling library. To install an Arduino library, check out our Library Installation Help Page.
For these Wirelings, you just need the Button/Switch example Arduino program:
After downloading, open the program in the Arduino IDE.
Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.
Upload Program
Upload the Button/Switch example Arduino program to your development board of choice.
Code
/*
TinyCircuits Button/Switch Wireling Example Sketch
This sketch will indicate if the button or switch
is active or inactive.
Written 30 July 2019
By Hunter Hykes
Modified 07 January 2020
By Hunter Hykes
https://TinyCircuits.com
*/
#include <Wire.h>
#include <Wireling.h>
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif
#define WIRELING_PIN A0 // pin corresponds to port (i.e. A0 -> PORT0, A1 -> PORT1, etc.)
#define LED_PIN 10 // For WirelingZero
//#define LED_Pin 13 // For TinyDuino, TinyScreen+, TinyZero, and RobotZero
void setup() {
SerialMonitorInterface.begin(115200); // start serial communications at 115200 Baud
Wire.begin(); // start I2C communications for Wireling Library
Wireling.begin(); // needed to reach Wireling ports on RobotZero and Wireling Adapter TinyShield
pinMode(LED_PIN, OUTPUT); // set the built-in LED pin as an output
pinMode(WIRELING_PIN, INPUT); // set the pin of the button/switch as an input
delay(500);
}
void loop() {
// NOTE: switch is active low so '0' is ON
if(!digitalRead(WIRELING_PIN)) {
SerialMonitorInterface.println("Active");
digitalWrite(LED_PIN, HIGH);
delay(1);
} else {
SerialMonitorInterface.println("Inactive");
digitalWrite(LED_PIN, LOW);
delay(1);
}
}
When the button or switch is active, the word "active" will be printed to the Serial Monitor and the onboard LED will turn on. When the button or switch is inactive, "inactive" will be printed to the Serial Monitor and the onboard LED will turn off.
If using a WirelingZero, make sure LED_PIN is set to 10. Otherwise, set it to 13.
Downloads
Large Button
Small Button
Slide Switch
Contact Us
If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.
Thanks for making with us!