Monitoring a Pi digital input

Is there a way to create a control that fires an event when the digital input on a Raspberry Pi changes state? or do I need to monitor each input using a timer loop?

Thanks,

Matt

We created multiple timers for each input we are monitoring and the timer raises an event when the input changes. You have to set the timer period pretty low. We have ours set at 10ms but you will need to experiment.

OK, could you share your timer code with me? Not sure how to raise an event (beginner here)…

if the status change from 0 to 1 and stay for a while it is no problem.
if you need exactly the peek for a ms you could use python with a std. out and using shell class in xojo.
in python you can register a rising/falling edge change, a function will call with a output message.
this is cpu friendly (stay idle).

good example here of monitoring a change in a digital input of the Pi
you can use interrupts also to be independant of any timer period.

3 Likes