BUTTON ON / OFF Recalbox



  • <pre class="tw-data-text vk_txt tw-ta tw-text-small" dir="ltr" style="unicode-bidi: isolate; font-family: inherit; border: none; padding: 0px 0.14em 0px 0px; position: relative; margin-top: 0px; margin-bottom: 0px; resize: none; overflow: hidden; width: 237.5px; white-space: pre-wrap; word-wrap: break-word; height: 456px;" data-placeholder="Tradução" data-fulltext=""><span lang="en"><span style="color: #212121; font-family: inherit;"><span style="white-space: pre-wrap;">Hello I am new to the forum and I have a big doubt . I'm trying to create an on switch off but I have Hello! I have a raspberry pi 2 model B , and from what I saw the pins that I use are pin 4 and pin 6 .</span></span></span> but recalbox off incorrectly, just cutting energy. I found a script that helps shut down properly , I would like to know which file should I paste this script. Sorry for my English. Thanks. Beto . Script #!/bin/python #This script was authored by AndrewH7 and belongs to him (www.instructables.com/member/AndrewH7) #You have permission to modify and use this script only for your own personal usage #You do not have permission to redistribute this script as your own work #Use this script at your own risk import RPi.GPIO as GPIO import os gpio_pin_number=4 #Replace YOUR_CHOSEN_GPIO_NUMBER_HERE with the GPIO pin number you wish to use #Make sure you know which rapsberry pi revision you are using first #The line should look something like this e.g. "gpio_pin_number=7" GPIO.setmode(GPIO.BCM) #Use BCM pin numbering (i.e. the GPIO number, not pin number) #WARNING: this will change between Pi versions #Check yours first and adjust accordingly GPIO.setup(gpio_pin_number, GPIO.IN, pull_up_down=GPIO.PUD_UP) #It's very important the pin is an input to avoid short-circuits #The pull-up resistor means the pin is high by default try: GPIO.wait_for_edge(gpio_pin_number, GPIO.FALLING) #Use falling edge detection to see if pin is pulled #low to avoid repeated polling os.system("sudo shutdown -h now") #Send command to system to shutdown except: pass GPIO.cleanup() #Revert all GPIO pins to their normal states (i.e. input = safe)



  • Hola Roberto, ¿tuviste suerte con esto? Estoy buscando también una forma de agregar un boton de encendido. Gracias!


Log in to reply
 

Want to support us ?

Join us on :

181
Online

28784
Users

14635
Topics

110651
Posts

Looks like your connection to Recalbox Forum was lost, please wait while we try to reconnect.