I have a problem with my Raspberry Pi, which is connected in a relay box in GPIO7 pin. I have tested with Gpio.board
and with gpio.bcm
without success with this code:
#This program connects with gpio7
#setup pins
#GPIO.setmode(GPIO.BOARD)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
#GPIO.setup(7, GPIO.OUT)#mode Board
while True:
GPIO.output(4, GPIO.HIGH)
#GPIO.output(7, GPIO.HIGH)#mode Board
time.sleep(5)
GPIO.output(4, GPIO.LOW)
#GPIO.output(7, GPIO.LOW) #mode Board
GPIO.cleanup() #devuelve los pines a su estado inicial
exit()
This is the error both in one way and the other:
Traceback (most recent call last):File"/home/pi/Desktop/RelayPrograms/5_7OnSleepOff.py", line 13, in GPIO.output(4, GPIO.HIGH)RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
Am I missing something?