Possible Syntax Error?

The following line of code is throwing a GPIO not defined error!!

GPIO.output(PWR_LED, not GPIO.input(PWR_LED))'

As you can see I have defined the pin =number and set it up as as output.

Abort_In_Pin = 37
Dir_Pin = 18
Rdy_LED = 40
PWR_LED = 37
IntensitySelect_Pins = (32,26,24,22)
Buzzer_Pin =38

GPIO.setmode(GPIO.BOARD)

GPIO.setup(Busy_Pin, GPIO.IN)
GPIO.setup(Run_Pin, GPIO.OUT)
GPIO.setup(Rdy_LED, GPIO.OUT)
GPIO.setup(PWR_LED, GPIO.OUT)
GPIO.setup(Toy_Sel_Pins, GPIO.OUT)
GPIO.setup(Abort_Out_Pin, GPIO.OUT)

So what could be wrong?

I don’t see where GPIO is defined in that code. Are you missing an import for it? Maybe

import RPi.GPIO as GPIO

You need to import GPIO or define it, e.g. from a function call, or as an instance of a class.

Hello,

I think that you accidently added the last apostrophe (or quote) ' by mistake.

Pual the extra apostrophe was a copy-paste error. The actual code does not have the extra apostrophe.

Yes, I have included the RPi.GPIO library.

import RPi.GPIO as GPIO
from time import sleep

Busy_Pin = 36
Run_Pin = 16
Toy_Sel_Pins = (8,10)
Abort_Out_Pin = 12
Abort_In_Pin = 37
Dir_Pin = 18
Rdy_LED = 40
PWR_LED = 37

Sorry, I did not include it in the original post.

All other GPIOs work as expected. It’s the only one not working throwing an error.

There is only one i in import. You have two.

Why do you have the same pin assigned to two variable names.
This is a no-no: :smirk:

Abort_In_Pin = 37
PWR_LED = 37

Same pin, two masters.

Sticking head in the sand with a blushing face.
Paul, you are right. The Abort_In_Pin should be pin 35. not 37
Thank you for pointing out my bad typing.

Sorry, man. I didn’t want to have to do this. But you’ve got detention for the next two weeks. :wink:

1 Like

LMAO :face_with_head_bandage: :face_with_head_bandage: :face_with_head_bandage: