Created
February 28, 2018 12:19
-
-
Save elktros/e98d4410fcb0fcfe279e0f8ad6cd9c3c to your computer and use it in GitHub Desktop.
Python Script for controlling a Relay with Raspberry Pi.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import time | |
in1 = 16 | |
in2 = 18 | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(in1, GPIO.OUT) | |
GPIO.setup(in2, GPIO.OUT) | |
GPIO.output(in1, False) | |
GPIO.output(in2, False) | |
try: | |
while True: | |
for x in range(5): | |
GPIO.output(in1, True) | |
time.sleep(0.1) | |
GPIO.output(in1, False) | |
GPIO.output(in2, True) | |
time.sleep(0.1) | |
GPIO.output(in2, False) | |
GPIO.output(in1,True) | |
GPIO.output(in2,True) | |
for x in range(4): | |
GPIO.output(in1, True) | |
time.sleep(0.05) | |
GPIO.output(in1, False) | |
time.sleep(0.05) | |
GPIO.output(in1,True) | |
for x in range(4): | |
GPIO.output(in2, True) | |
time.sleep(0.05) | |
GPIO.output(in2, False) | |
time.sleep(0.05) | |
GPIO.output(in2,True) | |
except KeyboardInterrupt: | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment