QMESAR
Posts: 55
Joined: Wed Sep 06, 2017 10:41 am

Please help me understand the warring Error

Mon Nov 27, 2017 8:55 am

Hi All,

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 example code below ,it seems that the resource is not returned when the script stop execution ,as when I run it a second time
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]

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Please help me understand the warring Error

Mon Nov 27, 2017 9:30 am

typo: wGPIO should be GPIO

QMESAR
Posts: 55
Joined: Wed Sep 06, 2017 10:41 am

Re: Please help me understand the warring Error

Mon Nov 27, 2017 9:33 am

Hi

Thank you very much for your help
I appreciate it very much

Regards
QMESAR

Return to “Beginners”