Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Teste de tempo do capacitor
  4. # Programa fica em loop até executar CRTL+c ou kill no processo
  5.  
  6. import RPi.GPIO as GPIO
  7. import time
  8.  
  9. GPIO.setwarnings(False)
  10. GPIO.setmode(GPIO.BCM)
  11.  
  12. def RCtime (RCpin):
  13.         reading = 0
  14.         GPIO.setup(RCpin, GPIO.OUT)
  15.         GPIO.output(RCpin, GPIO.LOW)
  16.         time.sleep(0.1)
  17.  
  18.         GPIO.setup(RCpin, GPIO.IN)
  19.  
  20.     while (GPIO.input(RCpin) == GPIO.LOW):
  21.                 reading += 1
  22.         return reading
  23.  
  24. while True:
  25.         print RCtime(23)