I have a basic question about Relay. My background is not related to electrical so I'm sorry if my wording is not correct.
I have a quite standard relay with 3 inputs: SIG, VCC and GND. And it has 2 LED, let's call LED1 for Relay power and LED2 for the switch. If I wire GND to GND, SIG to pin 31, and VCC to 5V, then I can switch the load by turning ON/OFF the pin 31. That means LED1 is always on and LED2 is toggle on/off base on pin 31 state.
Now I want to control the relay power programmatically so instead of wiring VCC to 5V, I wire VCC to pin 32. That means if I want to switch on the load, I will turn on pin 32 first and then turn on pin 31. But what really happened is that after turning on pin 32, LED1 is ON and then right after turning on pin 31, LED1 is off and LED2 is on which means I cannot switch on the load either.
Here is what I tested
#! /usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(31,GPIO.OUT)
GPIO.setup(32,GPIO.OUT)
#turn on relay VCC
GPIO.output(32,GPIO.HIGH)
time.sleep(2)
#turn on switch
GPIO.output(31,GPIO.HIGH)
print("done")
time.sleep(5)
GPIO.cleanup()
Can anyone help to explain why I couldn't control both signals of the relay?
Updated: Here is the link to the relay: http://wiki.sunfounder.cc/index.php?title=Relay(HIGH)_for_Arduino_and_Raspberry_Pi