Let say we have some variable x, initially x=0.
Whenever x changes its values from 0 to 1, click some button A
Whenever x changes its values from 1 to 2, click some button B
Whenever x changes its values from 2 to 0, click some button C
...
How to do that ?
Here's a simple example that updates
x
once a second and uses atrace
on the variable to invoke a button press when it's updated, with the specific button depending on the new value.