Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6815

MicroPython • start timer after "if" statement

$
0
0
I am trying to start a timer after a push button has been pressed.
Now I don't actually know how best to do this.
I thought the following, but this gives an error:
OSError: [Errno 12] ENOMEM
is this actually the right way?
Tnx.

Code:

from machine import Pin, Timertest6       = Pin(6,  Pin.OUT)test7       = Pin(7,  Pin.OUT)test6 . value(0)test7 . value(0)button=Pin(22, Pin.IN, Pin.PULL_DOWN)def test (source):    test6.value(1)    while True:        if button.value() == 0:        Timer(period = 2000, mode = Timer.PERIODIC, callback = test)        test7 . value(1)

Statistics: Posted by trixo — Sun Jan 07, 2024 11:42 am



Viewing all articles
Browse latest Browse all 6815

Trending Articles