3 4 5
GameboyRMH
GameboyRMH MegaDork
6/23/17 9:20 a.m.

Yeah keypress detection wasn't working, I rejiggered it. If this works OK I can modify it to make it work more like a conventional RC car. As-is, it continuously follows the last command until you press something else:

https://pastebin.com/nww03GG6

tuna55
tuna55 MegaDork
6/23/17 9:31 a.m.

Thanks!!!

tuna55
tuna55 MegaDork
6/23/17 8:13 p.m.

Warning (from warnings module): File "/home/pi/RC car code from gameboy.py", line 15 GPIO.setup(pwmpinL, GPIO.OUT) #set left motor's pin to output mode RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.

Warning (from warnings module): File "/home/pi/RC car code from gameboy.py", line 16 GPIO.setup(pwmpinR, GPIO.OUT) #set right motor's pin to output mode RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.

Warning (from warnings module): File "/home/pi/RC car code from gameboy.py", line 17 GPIO.setup(directionL, GPIO.OUT) #set right motor's pin to output mode RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.

Warning (from warnings module): File "/home/pi/RC car code from gameboy.py", line 18 GPIO.setup(directionR, GPIO.OUT) #set right motor's pin to output mode RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. Use W/A/S/D to move, numbers 1~4 to adjust movement speed. Press C to exit Traceback (most recent call last): File "/home/pi/RC car code from gameboy.py", line 95, in getch = getChar() File "/home/pi/RC car code from gameboy.py", line 87, in getChar return getChar._func() File "/home/pi/RC car code from gameboy.py", line 74, in _ttyRead fd = sys.stdin.fileno() io.UnsupportedOperation: fileno

GameboyRMH
GameboyRMH MegaDork
6/24/17 2:09 a.m.

That error seems to be caused by the running the script from within IDLE, Make sure you're running straight from the terminal with "python gameboy.py"

https://stackoverflow.com/questions/31080829/python-error-io-unsupportedoperation-fileno

I assume you also get the GPIO.setup warnings with your own working test scripts?

GameboyRMH
GameboyRMH MegaDork
6/24/17 10:22 a.m.

Found the cause of the GPIO.setup warnings and a way to take care of them:

http://raspi.tv/2013/rpi-gpio-basics-3-how-to-exit-gpio-programs-cleanly-avoid-warnings-and-protect-your-pi

tuna55
tuna55 MegaDork
6/26/17 6:45 a.m.

Weird, the other scripts I was using that I generated were not giving me any warnings.

tuna55
tuna55 MegaDork
6/26/17 6:45 a.m.

If it wasn't clear, it crashed after giving me warnings.

GameboyRMH
GameboyRMH MegaDork
6/26/17 8:03 a.m.

Yeah don't worry about the warnings for now, just run the script from the terminal and see if it works.

3 4 5

You'll need to log in to post.

Our Preferred Partners
eQ70cUD1Y3A0yvmGy0tcx5xKPXgY4lB6Lc8JvtTlPCPsqZWVJRpCEfDYJ9CwSpzi