2

I am attempting to create a button on my Retro Pie emulator case (A gutted NES), using the old reset switch, to exit out the of current game and go back to the menu.

Then I realized it just required a simple click of the escape key so I wrote code to emulate that.

import uinput
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)

device = uinput.Device([uinput.KEY_ESC])

while True:
     if GPIO.input(17) == True:
             device.emit.click(uinput.KEY_ESC)
             time.sleep(1)

I then put it in the rc.local file with the following command

sudo python /home/pi/BootScripts/reset.py &

it does not work at start up, but i did test the code by just running it through command line and looking at the output.

When I boot up I get the following error.

startpar service(s) returned failure reset.py

Can anyone help, this is driving me insane! I have never had so much trouble on such a simple thing. It probably doesn't help I had zero python experience when i started this, but, any ideas?

  • A possible solution might be that some modules haven't fully loaded, thus the RPi.GPIO can't function correctly? Can you create a pastebin (paste.ubuntu.com works fine) with your full dmesg output and link to it here? – RPiAwesomeness Sep 7 '14 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.