from picozero import pico_led, Button, LED, Buzzer
from time import sleep
led16 = LED(16)
button12 = Button(12, pull_up = False)
button15 = Button(15, pull_up = False)
buzzer14 = Buzzer(14)
global cont
cont = True
global count
count = 0
def cont_false():
global count
global cont
if count >= 10:
cont == False
print(cont)
def Timer_start():
led16.on()
global cont
global count
sleep(5)
while cont:
buzzer14.toggle()
sleep(0.2)
buzzer14.toggle()
count += 1
print(count)
sleep(0.3)
button15.when_pressed = Timer_start
button12.when_pressed = cont_false
while True:
pico_led.toggle()
sleep(0.5)
so its meant to be so that cont_false
sets cont to false and stops the while loop in
Timer_start
but it does nothing
The While loop in Timer_start
runs once outputting 1 then it keeps beeping but never outputs again
im using micro python on a Raspberry Pi Pico
when_pressed
functions are run in an interrupt, and it might be an interrupt that's higher priority than the USB stack, so it might interfere with USB communication. Maybe you could say what you're actually trying to do and we can help write more sensible code that achieves the goal.