I recently purchased a Sunfounder single relay board (https://www.amazon.ca/gp/product/B013GAGFOU) and am attempting to use it with my Pi. I have connected the board's GND, VCC, and SIG wires to Pi pins 2 (5V), 6 (GND), and 7 (GPIO 4), and created a basic script to test functionality:
import RPi.GPIO as GPIO import time pin = 4 GPIO.setmode(GPIO.BCM) GPIO.setup(pin, GPIO.OUT) try: while 1: GPIO.output(pin, GPIO.LOW) print "low" time.sleep(0.5) GPIO.output(pin, GPIO.HIGH) print "high" time.sleep(0.5) except KeyboardInterrupt: GPIO.cleanup()
The expected result is the the relay turns on for half a second and then turns off. However, the relay is being turned on and not turned off at all, despite the pin being cycled.
Interestingly, the status LED on the board is always on.. it is on but dim when the pin is high, and on and full brightness when the pin is low. I'm not sure what I'm doing wrong, so any input would be appreciated.