Skip to content

Instantly share code, notes, and snippets.

@s4l1h
Created November 7, 2021 12:07
Embed
What would you like to do?
Raspbery pi Relay
#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT) # It does Auto set LOW and Turn Relay ON
print(GPIO.input(17))
sleep(5)
GPIO.output(17, GPIO.HIGH) # Off Relay
print(GPIO.input(17))
sleep(5)
GPIO.output(17, GPIO.LOW) # ON Relay
print(GPIO.input(17))
sleep(5)
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment