Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python.I'm using a raspberry pi. What is code that will exit the program when you push on the joystick using a global variable. This isn't
Python.I'm using a raspberry pi. What is code that will exit the program when you push on the joystick using a global variable. This isn't working.
def pushed_middle(event): global x if event.action == ACTION_PRESSED: x = 0 sense.stick.direction_middle = pushed_middle while True: if x == 0: sense.clear() os.system("sudo shutdown now -P") time.sleep(5) elif x == 1: sense.clear() raise SystemExit time.sleep(5)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started