Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Do you believe that Matilda overreacted to James? Why or why not?

Answered: 1 week ago