Coding with A touchLED

I’m trying to make A code where when I press my touchLED(ouchled_9) it begins my code. Right now, when I press the touchLED, nothing happens. Could someone look at my code and maybe point me in the right direction? Thank you!
image

you might want to change the while statement to an wait until, how you do this is you add a not after the while

while not touchled_9.pressing():
    Your program

Hopefully that helps!
-Blaziumm

I feel like you have asked this same question several times over the last few days.

The general idea will be to wait for the button press and then continue with running whatever code you want.

# Begin project code

# wait for touchled press
while not touchled_9.pressing(): 
    sleep(10, MSEC)

# now run the code
drivetrain.drive(FORWARD)

6 Likes

Yeah I’ve had problems with this a lot. Sorry if I’ve been asking too many questions but I don’t know what I’m missing and I still don’t really get it

Did you try the code I posted ?

The simple sequence of events in pseudo code is after running the program.

The programs waits for the touchled to be touched.
When the touchled is touched, the program continues and runs the remaining code.
2 Likes

ok I’ll try it
Thank you so much for your help btw, I literally just started python and I’m not that smart :sweat_smile: