Created
August 30, 2014 10:18
-
-
Save PierfrancescoElia/63f206620372054c2a65 to your computer and use it in GitHub Desktop.
Azionamento relè con GPIO
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
Questo programma permette di azionare relè passo-passo pre-esistenti come quelli delle luci di casa o, di azionare un cancello elettrico, sdoppiando i fili del citofono. Tutto ciò può essere eseguito anche tramite interfaccia Web. |
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
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import time | |
GPIO.setmode(GPIO.BCM) | |
# inserire i pin ai quali sono collegati i relè da azioinare | |
pinList = [3] | |
# loop through pins and set mode and state to 'low' | |
for i in pinList: | |
GPIO.setup(i, GPIO.OUT) | |
GPIO.output(i, GPIO.HIGH) | |
# tempo in cui il relè rimane eccitato | |
SleepTimeL = 0.25 | |
# ciclo | |
try: | |
GPIO.output(3, GPIO.LOW) | |
print "RELE' AZIONATO! :)" | |
time.sleep(SleepTimeL); | |
GPIO.cleanup() | |
# Termine del programma | |
except KeyboardInterrupt: | |
print " Quit" | |
# Reset impostazioni GPIO | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment