If you want to see how the things you make this time work, please see here (youtube video).
I will connect the wire to this relay module at once. GND (green) IN1 (blue) IN2 (red) IN3 (ash) IN4 (white) VCC (black) GND (green) >> Pin.6 IN1 (blue) >> Pin.11 GPIO 17 IN2 (red) >> Pin.7 GPIO 4 IN3 (ash) >> Pin.5 GPIO 3 IN4 (white) >> Pin.3 GPIO 2 VCC (black) >> Pin.2 5V
relay.py
import RPi.GPIO as GPIO
import time
#GPIO.setwarnings(False)
#If you get an error like a pin is being used, add this and it will work.
GPIO.setmode(GPIO.BCM)
pinlist = [2,3,4,17]
for i in pinlist:
GPIO.setup(i,GPIO.OUT)
GPIO.output(i,GPIO.HIGH)
try:
for i in pinlist:
GPIO.output(i,GPIO.LOW)
time.sleep(2)
finally:
print("End of Program!")
GPIO.cleanup()
When you do this, the lights on the relay module will light up in sequence.
How to use this relay module is also explained in Youtube, so please have a look if you like it. If you have any questions, please use the comment section of the video or the comment section of this article. Also, if you like it, please subscribe to the channel (https://www.youtube.com/channel/UCDYbu9aViDvkubFcwgbbKDA).
Recommended Posts