Given:
Raspberry Pi3
Sunfounder 2 channel relay
plugged into 3.3v
plugged into ground
plugged into pin 18
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, GPIO.HIGH)
time.sleep(5)
GPIO.output(18, GPIO.LOW)
The light on the relay comes on only when I swap the high and low in the code that I saw on YouTube. Why is mine working backwards?
Mine has to be like the following snippet:
GPIO.output(18, GPIO.LOW)
time.sleep(5)
GPIO.output(18, GPIO.HIGH)