2

We are trying to write a code that starts raspberry pi when you hit the joystick of the sense hat.

Code that acknowledges when joy stick is pressed

from sense_hat import SenseHat
sense = SenseHat()
while True: 
    for event in sense.stick.get_events():
        print(event.direction, event.action

outputs "middle pressed middle released"

Now I need code that when I press middle and release it starts up the raspberry pi or more importantly turns it off.

Andy J
  • 1,479
  • 6
  • 23
  • 40
  • Please don't forget to provide feedback to folks who have been kind enough to devise answers to your other, related questions. – Mark Setchell Nov 16 '21 at 22:40
  • "Thanks for the feedback! You need at least 15 reputation to cast a vote, but your feedback has been recorded." I have tried. – speedee_doge Nov 17 '21 at 15:29
  • It will not be possible to **start** a Raspberry Pi with the Sense Hat joystick as all it does is send a keyboard `Enter` key. This must be handled by code within the operating system. Shutdown is easy enough to do. Look for `python` code to send shutdown signal to a Linux system or send terminal commands from a script. – Ari Jan 02 '22 at 01:56

0 Answers0