Skip to content

Large/Small Button & Switch Wireling Python Tutorial

This page includes an example program that shows you how to read the HIGH/LOW state on the Wireling Pi Hat for a small button, a large button, and a switch.

Large Button Technical Details

FMS8HSMA Specs

  • Height 7mm

    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)
    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)

      Materials

      Hardware

      Required Software

      • Python 3 (Python 2 is not supported!)
      • All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)

      Hardware Assembly

      Plug your Wireling into the port you plan on using!

      If you want to use a different port, you just need to change the port value in the program mentioned later.


      Programming

      The Wireling Python package includes helper functions that make I/O programming, like for a button, easy. There is even an I/O example for reading the digital signal in the Wireling package that we will use here:

      wireling_input-example.py
      # Wireling Simple Input Example
      # This example can be used with the Large Button, Small button, Switch, 
      # and Digital Hall Sensor Wirelings to read the digital state
      
      import time
      import tinycircuits_wireling
      
      wireling = tinycircuits_wireling.Wireling()
      
      while(True):
          wireling.digitalRead(0) # Insert 0-3 correlating with the port label on pi hat
          time.sleep(0.2)
      

      Run Program

      Navigate in the terminal to the Wireling examples folder and type:

      python3 wireling_input-example.py
      

      After you run the program, you should see a 1 printed to signify a HIGH state every 0.2 seconds. Once you press the Large Button Wireling, you should see a 0 printing every 0.2 seconds as it is still pressed to signify a LOW state.


      Contact Us

      If you have any questions or feedback, feel free to email us at info@tinycircuits.com or make a post on the forum.

      Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!

      Thanks for making with us!


      Downloads