def try_api(img, access_token): try: a = go_api(img, access_token) if a == 'yes': print('reday to open door') open_door() GPIO.clean() time.sleep(5) if a == 'no': pass except: pass
#!usr/bin/env/ python ## enciende.py #Importamos la libreria y le cambiamos el nombre a GPIO import RPi.GPIO as GPIO import time #Establecemos el sistema de numeracion que queremos, #eb este caso el sistema BCM GPIO.setmode(GPIO.BCM) #Configuramos el pin GPIO 5 como una salida GPIO.setup(5, GPIO.OUT) #Encendemos el led for i inrange(0,5): GPIO.output(5, GPIO.HIGH) time.sleeo(1) GPIO.clean()
try: humedad, temperatura = DHT11_data() print("Humedad:", humedad, "Temperatura", temperatura) if humedad > 50.0: gpio.output(led_r, True) gpio.output(led_g, False) else: gpio.output(led_r, False) gpio.output(led_g, True) sleep(20) except KeyboardInterrupt: gpio.clean() print("Programa terminado") break
def stopGPIO(): GPIO.clean()
try: import RPi.GPIO as GPIO except RuntimeError: print ("Error importing RPi.GPIO! Try using sudo") GPIO.setmode(GPIO.BOARD) mode = GPIO.getmode() if mode is 10: print "RPi.GPIO Loaded. Pins set to BOARD" elif mode is 11: print "RPi.GPIO Loaded. Pins set to BCM" else: print "RPi.GPIO Loaded. ERROR: Check pin setup GPIO.getmode()" GPIO.setup(32,GPIO.OUT) p = GPIO.PWM(32,60) p.start(50) #p.ChangeFrequency(60) #p.ChangeDutyCycle(80) p.stop() GPIO.clean()
def clear_pull_up_down(self) -> None: # TODO Find better way GPIO.clean(self._pin) GPIO.setup(self._pin, GPIO.IN)