I'm VERY new to Python and am currently programming a Photobooth. I want to deactivate the Buttonpress until a coin is tossed and want it to deactivate when the photo is Saved. I just don't get how i could code it that the action ButtonPress works until something happens.
I know my code is very chaotic but it works fine overall. I program it on a Raspberry pi and have the Coin Acceptor on GPIO 18. I get 10 Pulses because it is a coin acceptor which only works with 1€ coins.
this is the code I'm using.
Would be awesome if somebody could lighten my darkness! Thanks in advance!
Try having a variable to store if the coin has been inserted:
then when a coin is inserted and you get the ten pulses:
on your bit of code where you detect your button press:
and on your code that takes a photo, when it's done and the photo is saved, set the variable back to 0
Additionally:
In comments, user highlighted that they didn't know how to detect the coincounter. Disregard the above code and do the following.
then, at the end of your your code, loop forever until a coin is inserted.