I've built a skee ball machine, and it works great! Now I want score kept without me doing it, and a Pi seemslike a good way. I've set up 7 momentary switches, and verified that a ball does, in fact, cause the contacts to close. Good start. Now what I have to do, is get scores attributed to each button and present the total to the LCD I'm using as a scoreboard. I have zero idea how to get that done. I've found several examples of using a button to fire up a LED, but can't find anything on the continuous loop needed to be able to assign values, and keep those values in a variable.
I know the pseudo codebelow won't work, but I'm offering it up just as a "I'm not just asking for a solution without at least thinking about it just a little bit," and a bit of context. I know "wait for press" won't work, I threw it in there to maybe start to test basics. And I don't know how to make certain that momentary contact doesn't occur while the program isn't at that point in the loop. I'm sure there is something easy and baked in.
So I don't know much, other than how to build a skee ball machine that can't keep score
Any guidance would be appreciated. I'm sure something is out there that I could learn to modify.
Thank you,
Stephen.
########################## bad pseudo code below:
from gpiozero import Button
from time import sleep
button100 = Button(2)
button101= button(3)
button50=button(4)
button40=button(17)
button30=button(27)
button20=button(22)
button10=button(10)
buttonReset=button(9)
score=0
#### Begin loop. No idea how to do this.
button100.wait_for_press()
score=score+100 #increments score based on value of the target hit
sleep(.5) #prevents "bounce" in the sensor from recording multiple scores
button101.wait_for_press()
score=score+100
sleep(.5)
button50.wait_for_press()
score=score+50
sleep(.5)
button40.wait_for_press()
score=score+40
sleep(.5)
button30.wait_for_press()
score=score+30
sleep(.5)
button20.wait_for_press()
score=score+20
sleep(.5)
button10.wait_for_press()
score=score+10
sleep(.5)
buttonReset.wait_for_press()
score=0
Print(score)
### Loop return