2

I'm fairly certain this is Raspberry Pi 101, but I've googled it and get results that aren't relevant.

I want to run script after a button press, but I want to disable further button presses until the code has finished running.

so something along the lines of

while True:
 Run = GPIO.input(XX)
 if Run == False: /counter intuitive I know
       XXXXXXX disable input from XX
       -other code
       -other code
       XXXXXXXX enable input from XX
6
  • 1
    Well depending on what's hanging off it you might be able to set the pin to an output suring the input handler. But unless you have event-driven code/an interrupt triggered off the pin (and it doesn't look like you do), just not testing the pin while executing the script should be enough. – Chris H Feb 16 '16 at 9:04
  • Let me try that. – ProjectPokket Feb 16 '16 at 9:07
  • Yup, that works. Thanks! on a completely different note, how do I mark that as an answer on here? – ProjectPokket Feb 16 '16 at 9:12
  • 2
    See: What should I do when someone answers my question?. Of course, someone would have to actually post the solution as an answer first. :P – goobering Feb 16 '16 at 11:19
  • Convert comment to answer? :) – Piotr Kula Feb 16 '16 at 21:47
0

Converting the Input to an Output while the code executed works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.