Código para Latch físico: Touch_calibrate.py

650 views

Published on

Código en Python para el hack de controlar un cerrojo con un Latch y una conexión en Raspbery Pi. Más información aquí: http://blogthinkbig.com/latch-cerrojo/

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
650
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Código para Latch físico: Touch_calibrate.py

  1. 1. #!/usr/bin/env python # Reading capacitive sensor with # a single GPIO pin import RPi.GPIO as GPIO, time # Tell the GPIO library to use # Broadcom GPIO references GPIO.setmode(GPIO.BCM) # Define function to measure charge time def RCtime (RCpin): measurement = 0 # Discharge capacitor GPIO.setup(RCpin, GPIO.OUT) GPIO.output(RCpin, GPIO.LOW) time.sleep(0.1) GPIO.setup(RCpin, GPIO.IN) # Count loops until voltage across # capacitor reads high on GPIO while (GPIO.input(RCpin) == GPIO.LOW): measurement += 1 return measurement max=0 min=9999 # Main loop while True: value=RCtime(27) if value > max: max=value elif value < min: min=value print '{0:3d} {1:3d} {2:3d}'.format(value,min,max)

×