I am trying to control a relay using a very simple python code:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(27, GPIO.OUT) GPIO.output(27, GPIO.HIGH) time.sleep(1) GPIO.output(27, GPIO.LOW)
Relay switches on, but seemingly
GPIO.output(27, GPIO.LOW) line does nothing. Relay does not switch off. I have tried different pins (17,24,27) but it didn't help.
If I run the code again it shows a warning message: "RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings."
I have found out that if i put
GPIO.cleanup() command to the bottom, relay switches off. But I suppose it is not proper way off switching off.
I have tried using
GPIO.output(27, 0) command, but it is not working, too.
That is the relay I am trying the control:
Thanks for your help!