I am new with python and PI. I have been looking all over for information about this but with no luck.
currently it works like this:
I start the program, I press the button and then it starts counting down with the LED's. But if I press the button it just continues onwards until it's finished and then I can press the button to start over again with the loop.

What I need it to do is this: While the counting is in progress and I need to reset it ( let's say I misspressed the timer ) then if I press it while it's running, then it needs to start over with the counting from the start of the loop.

Thanks for reading. I hope you can help me out on this one.

from sense_hat import SenseHat
from time import sleep

sense = SenseHat()
g = [0, 255, 0]                #Green
r = [255, 0, 0]              # Red
x = [0, 0, 0]                    # Empty
y = [255, 128, 0]            # Yellow
w = [255, 255, 255]          # White

s = 60       # Sec Counter

done = [
    r, r, w, w, w, w, r, r,
    r, w, r, r, r, r, w, r,
    w, r, r, r, r, w, r, w,
    w, r, r, r, w, r, r, w,
    w, r, r, w, r, r, r, w,
    w, r, w, r, r, r, r, w,
    r, w, r, r, r, r, w, r,
    r, r, w, w, w,w, r, r

counting = True
    timer = []

    for event in sense.stick.get_events():
        if even.action ==”pressed”:                            
            if event.direction == “middle”:  

                for i in range(64):
                    if i > s:                    


                for i in range (0,s) :
                    timer[i] = y

                for i in range(0, s):
                    timer[i] = r

                sense.show_message(“press To Start!”)
  • If I need to clarify myself more please say so. Still haven't found the answer to this yet. :/ – Wartoc Oct 15 '18 at 8:14

Your Answer

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

Browse other questions tagged or ask your own question.