Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4151

Python • RuntimeError: The GPIO channel has not been set up as an OUTPUT for simple robot wheels

$
0
0
I am using a very basic test code provided at the end of this video linked below (I'm basically trying to rebuild her robot with a few extra mods but I haven't even added the mods yet)
https://www.youtube.com/watch?v=Bp9r9TGpWOk
I keep getting this error:
RuntimeError: The GPIO channel has not been set up as an OUTPUT
It marks the error at the first line of my forward function.
I have tried googling the solution and this is the only link that comes close to solving my issue but not quite as I'm not using GPIO.cleanup(), so I have no idea what else my issue can be. I've reviewed the code a dozen times, and it should be working, as I'm essentially doing this but with some extra steps:

Code:

import timeimport RPi.GPIO as GPIOGPIO.setwarnings(False)GPIO.setmode(GPIO.BOARD)GPIO.setup[29, GPIO.OUT]GPIO.setup[31, GPIO.OUT]#30 GNDGPIO.setup[32, GPIO.OUT]GPIO.setup[33, GPIO.OUT]GPIO.output(29, True)time.sleep(3)GPIO.output(29, False)GPIO.output(31, True)time.sleep(3)GPIO.output(31, False)GPIO.output(32, True)time.sleep(3)GPIO.output(32, False)GPIO.output(33, True)time.sleep(3)GPIO.output(33, False)time.sleep(3)exit()
And this code worked perfectly fine. I don't know why it shit the bed as soon as I brought classes into the equation. The pins all work, and they all respond to the pi calling them out exactly like this. I think it must be something in my syntax that's making it freak out and throw this error. I removed all the extraneous stuff I added in for my future mods (except for some of the imports), and nothing fixed it. I'm linking my code below as I've been having issues with webpages getting rid of all of my formatting:
https://docs.google.com/document/d/1_Y5 ... sp=sharing
Again, I'm following her code exactly, so I'm not sure where I could have gone wrong on this. Again, I get the error attached to the first line of my forward function.

Statistics: Posted by ameerkatofficial — Thu Jul 25, 2024 8:37 pm



Viewing all articles
Browse latest Browse all 4151

Trending Articles