Tiny FX: Add Momentary Push Buttons

I have a project where I need to add 3 momentary push button switches to the Tiny FX. Each button would turn on a different LED.

Is my best option to use the Pimoroni IO Expander Breakout (IO Expander Breakout)

Or is there a better option? Thanks

Hi,

I’m not sure how comfortable you are with wiring, but if it’s only every going to be 3 buttons you need then you could make use of the Qw/ST and Sensor connectors to give your 3 digital pins (with power and ground).


You would need these two cables with either Pins or Sockets.

In code, when creating your TinyFX, you would add init_i2c=False to make the Qw/ST connectors free for this use. Then create Pin objects like so:

tiny = TinyFX(init_i2c=False) 
button_a = Pin(tiny.I2C_SDA_PIN)
button_b = Pin(tiny.I2C_SCL_PIN)
button_c = Pin(tiny.SENSOR_PIN)

Otherwise, yes IO Expander would be the other option. Sadly we don’t do that with a Qw/ST connector yet, so you would similarly need the 4 pin cable I linked to above, along with some pin headers, and some soldering.

Hope that helps

Thank you! That helps a lot!

With your example code, I’m connecting each push button to a separate pin wire as well as a ground wire and then simply reading the value?

You’re welcome.

Correct, though you will need to set the Pin to have a pull-up. So more accurately the code would be like:

from machine import Pin
from tiny_fx import TinyFX

tiny = TinyFX(init_i2c=False) 
button_a = Pin(tiny.I2C_SDA_PIN, Pin.IN, Pin.PULL_UP)
button_b = Pin(tiny.I2C_SCL_PIN, Pin.IN, Pin.PULL_UP)
button_c = Pin(tiny.SENSOR_PIN, Pin.IN, Pin.PULL_UP)

You would then call button_a.value() which will return True or 1 when released, and False or 0 when pressed. If you want this logic to be reversed, wire your buttons to 3.3V and use Pin.PULL_DOWN.

In fact, that could be a good way around there only being two spare ground pins. Have two of the buttons wired to GND with PULL_UP, and the 3rd wired to 3.3V with PULL_DOWN (or the other way around if you prefer).

You could just daisy chain all the grounds together on one ground pin.
If you have a Pimoroni breakout that doesn’t have the QWICC connector, like the IO expander. You could just solder on one of these.
Breakout Garden to STEMMA QT / Qwiic Adapter
I just solder it on the back side using a male 5 pin header.
Then use a cable, 4 Pin JST-SH Cable (Qwiic, STEMMA QT, Qw/ST)

Another switch option is the Encoder wheel.
RGB Encoder Wheel Breakout
That gets you 5 buttons, some more RGB LED’s and the encoder wheel. It’s got the same onboard Micro Controller that the IO Expander does.

Thank you so much! I now have a couple of options to try.

1 Like

I happen to already have a Breakout Garden to STEMMA QT / Qwiic Adapter so I feel like I have several solutions to try now for my project. Thanks for the help!

1 Like