6.3. Button edge detector

If you need an action when the button is pressed, more preciesley at the one moment it is pressed, then an 'edge detector' is needed.

The logic is build as follows: current state of gpio input is compared with the last state. Use a variabale to preserve last state. When current state is '0' an dlast state is '1', then a button press has happened.

set lastValue = '1'
    if lastValue == '1' and if gpio23 sensorvalue == 0
        send broadcast 'button pressed'
    end if
    set lastValue = gpio23 sensorvalue 

This effort is needed because gpioserver does not provide edge detection or event based inputs.

Sample code edgedetektor piandmore_gpioserver_buttontoggle.sb