Skip to content

Instantly share code, notes, and snippets.

@izzuddin91
Created July 23, 2019 14:41
Show Gist options
  • Save izzuddin91/2db3b223224af9639a526595048bbe0f to your computer and use it in GitHub Desktop.
Save izzuddin91/2db3b223224af9639a526595048bbe0f to your computer and use it in GitHub Desktop.
setting up relay for hydroponic projects
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and s$
while True: # Run forever
GPIO.output(8, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second -> use this to set the interval for water pump
GPIO.output(8, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment