Code example for adding an Push Button to Matrix Devices

Hi all,

I’m currently trying to figure out how I could add a push button to my matrix creator using the matrix-lite-js library.
Are there any code examples available?

Maybe I’m just lacking of some GPIO Knowledge. Right now I would read every x ms the GPIO State but this sounds very ressource consuming, is there any listener for that?

Thanks in advance!
Carlos

PS: What about the IR Sensors on the Matrix Creator, will these be added to the matrix-lite at some point?

@Mexolotl,

Reading the GPIO periodically to check if the button has been pressed should work fairly efficiently. We don’t have any event listeners for that implemented in the code so the way you’re doing it makes sense.

As for the IR sensor, adding it to MATRIX Lite is farther down in our roadmap but definitely a feature we plan to have at some point.

Best,
Samreen

1 Like

@Samreen thanks for the clear answer!

Has anyone done this with the matrix devices?
Any idea what would be a good interval to read for a push button?
I would guess a press of a push button should have a duration of about 100ms…

@Mexolotl,

100ms should work, you could also try 50ms or less. It would depend on the button debouncing. You may want to test out and see what delay duration registers one button press as one instead of multiple, as consistently as possible.

I could test this with my MATRIX device and let you know this week.

Best,
Samreen