What errors result when you run the script?
Here are a few potential errors I can see:
- you could use
from time import sleep
instead of import time
- you haven't put in the shebang line at the start of the script (
#!/usr/bin/env python
) - this tells what you are using to run it what it is.
- You likely don't need
GPIO.output(12,GPIO.LOW)
as I would of thought that GPIO.output(12,GPIO.HIGH)
would override it (you can also use GPIO.output(12, True)
- With the
GPIO.setup(GPIO.OUT)
line, I think you need to specify the pin number - so it would be GPIO.setup(12, GPIO.OUT)
Another problem could be that you don't have it wired correctly - you can get help with pin numbers etc here. Try not get confused between the Board and BCM numbering
So something like this should work:
#!/usr/bin/env python
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.output(12, True))
print "On"
sleep(3)
print "Off"
GPIO.output(11, False)
GPIO.cleanup()
)
in the code above otherwise... – Wilf Jul 10 '19 at 17:41