Home>
import wiringpi
import time
button_pin = 17
wiringpi.wiringPiSetupGpio ()
wiringpi.pinMode (button_pin, 0)
wiringpi.pullUpDnControl (button_pin, 2)
    if (wiringpi.digtalRead (button_pin) == 0):
        print ("Measurement start")
    else:
        print ("Measurement stop")

I tried to set up a program to show that the tact switch is detected twice with python (when I press the first time, the measurement starts when I press the second time), but it doesn't work well. Can you give me advice?

  • Answer # 1

    Set a measurement start flag
    If the switch is detected ON, check the flag, stop measuring if measurement is in progress, start measurement if measurement is stopped.

    So, the error is an indentation error and it means that the source is written

    #Place the source into the'''frame by pressing the<code>button

Related articles