8 relay GPIO pins not working
Posted: Mon Nov 13, 2017 12:39 pm
Hi, I'm a complete novice, I've been looking at different forums, but have not come up with a solution yet.
I'm using RPi 3 Model B - latest Raspian
I'm trying to run simple Python 3 - 6.3 code to test an 8 way 5v relay which has an external 5v power sourse, which I've grd onto GPIO grd pin.
please see code below, I'm I missing something
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# init list with pin numbers
pinList = [4,17,27,22,18,23,24,25]
# loop through pins and set mode and state to 'low'
for i in pinList:
GPIO.setup(i, GPIO.OUT)
GPIO.output(i, GPIO.HIGH)
# time to sleep between operations in the main loop
SleepTimeL = 0.2
# main loop
try:
while True:
for i in pinList:
GPIO.output(i, GPIO.HIGH)
time.sleep(SleepTimeL);
GPIO.output(i, GPIO.LOW)
pinList.reverse()
for i in pinList:
GPIO.output(i, GPIO.HIGH)
time.sleep(SleepTimeL);
GPIO.output(i, GPIO.LOW)
pinList.reverse()
# End program cleanly with keyboard
except KeyboardInterrupt:
print (" Quit")
# Reset GPIO settings
GPIO.cleanup()
There has been some info on forums, saying the 3V3 should be connected to COM on the relay board - Pins showing as below
VCC
GND
IN1
IN2
IN3
IN4
IN5
IN6
IN7
IN8
COM
GND
When running the code, there are not Syntax errors at all, but when connecting relays, nothing happening, just power light on.
According to Keystudio website VCC & GND are for 5v external power! Doesn't say anything about the COM??
Please help!!?
I'm using RPi 3 Model B - latest Raspian
I'm trying to run simple Python 3 - 6.3 code to test an 8 way 5v relay which has an external 5v power sourse, which I've grd onto GPIO grd pin.
please see code below, I'm I missing something
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# init list with pin numbers
pinList = [4,17,27,22,18,23,24,25]
# loop through pins and set mode and state to 'low'
for i in pinList:
GPIO.setup(i, GPIO.OUT)
GPIO.output(i, GPIO.HIGH)
# time to sleep between operations in the main loop
SleepTimeL = 0.2
# main loop
try:
while True:
for i in pinList:
GPIO.output(i, GPIO.HIGH)
time.sleep(SleepTimeL);
GPIO.output(i, GPIO.LOW)
pinList.reverse()
for i in pinList:
GPIO.output(i, GPIO.HIGH)
time.sleep(SleepTimeL);
GPIO.output(i, GPIO.LOW)
pinList.reverse()
# End program cleanly with keyboard
except KeyboardInterrupt:
print (" Quit")
# Reset GPIO settings
GPIO.cleanup()
There has been some info on forums, saying the 3V3 should be connected to COM on the relay board - Pins showing as below
VCC
GND
IN1
IN2
IN3
IN4
IN5
IN6
IN7
IN8
COM
GND
When running the code, there are not Syntax errors at all, but when connecting relays, nothing happening, just power light on.
According to Keystudio website VCC & GND are for 5v external power! Doesn't say anything about the COM??
Please help!!?