I using the following code from the book Programming the Raspberry Pi by Dogan Ibrahim.
The code execute and my LED is flashing however I get the warning/error
Code: Select all
wGPIO.cleanup()
NameError: name wGPIO is not defined
the warning is reported that Channel is already in use .Aany help is appreciated
Regards
QMESAR
Code: Select all
import RPi.GPIO as GPIO # import GPIO module
import time # import time module
#---------------------------------------------------------------------
#definitions
#---------------------------------------------------------------------
LED = 18 # Pin 18 as Drive Pin LED
ON = 1 # define ON as 1
OFF = 0 # define OFF as 0
#--------------------------------------------------------------------
# Configurations
#--------------------------------------------------------------------
GPIO.setmode(GPIO.BCM) # set BCM pin numbering
GPIO.setup(LED, GPIO.OUT) # Configure channel 18 as output
#--------------------------------------------------------------------
#blink the led for 10 times and stop the execution
#---------------------------------------------------------------------
for i in range (0, 10): # Do 10 times
GPIO.output(LED, ON) # turn ON LED
time.sleep(1) # wait 1 second
GPIO.output(LED, OFF) # turn OFF LED
time.sleep(1) # wait 1 second
wGPIO.cleanup() # clean up
/code]