Iterate through UniPi1 digital IN/OUTs
I want to operate a 4x4 switch matrix with the UniPi1
digital IN/OUT 1-4: matrix rows 1-4
digital IN/OUT 5-8: matrix columns 1-4
I want to iterate now through the digital_IO 1-4, so to check the switch status of each row by reading digital_IO 5-8.
My simple question is: how to code this in ST??
I mean, how to call the unipi digital_IO using a variable?
Thanks a lot for support!
this is not possible, since digital inputs are only inputs, not outputs. For scanning switch matrix, you need to apply voltage to each column separately, and then read rows (or vice versa). Theoretically it can be done with relay outputs (4 ROs to columns, 4 DIs to rows), but relays are really not the right components for this type of application.
If you know a bit of electronics, try looking into this: https://www.eleccircuit.com/16-key-encoder-using-ic-74c922n/
Reading the BCD code in FBD or ST is a piece of cake.
Thanks for reply and for the link!
I assumed the digital INs could also act as OUTs.. pitty.. :/
Do you know if there's any product that I can buy of the shelve or a product that uses the I2C? It's just a time issue...
I found a capacitive keypad here: https://www.robotshop.com/uk/16-button-capacitive-keypad-module.html
and a module that can connect the keypad via I2C here: https://www.robotshop.com/uk/16-keys-capacitive-touch-ttp229-i2c-module.html
Before I buy it - can UniPi1 cope with this?
It can be theoretically connected to the UniPi 1.1, you will not get it working directly in the Mervis. Mervis doesn't have any support for custom I2C devices. You would have to write some I2C - Modbus bridge in Python for example.