SlideShare a Scribd company logo
#!/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)

More Related Content

PDF
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
DOCX
Practical no 2
PDF
VERILOG CODE FOR Adder
PDF
An evaluation of LLVM compiler for SVE with fairly complicated loops
PPTX
Lecture 3: Strings and Dynamic Memory Allocation
ODP
Dive into CPython Bytecode
PDF
3 rd animation
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
Practical no 2
VERILOG CODE FOR Adder
An evaluation of LLVM compiler for SVE with fairly complicated loops
Lecture 3: Strings and Dynamic Memory Allocation
Dive into CPython Bytecode
3 rd animation

What's hot (20)

PPT
Loops (1)
PPT
Algorithm cup 2010
PDF
C coroutine
PDF
Q4.11: NEON Intrinsics
PDF
Certifying (RISC) Machine Code Safe from Aliasing (OpenCert 2013)
PDF
Satellite link-budget-analysis-matlab-code
PDF
Compilation of COSMO for GPU using LLVM
PDF
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
PPTX
Python with a SWIG of c++
PDF
Scaling FastAGI Applications with Go
PDF
Concurrency in Python4k
PPTX
PHP in 2018 - Q1 - AFUP Limoges
PDF
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
DOCX
Array using recursion
PDF
Q4.11: Using GCC Auto-Vectorizer
PPT
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
PPT
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
PDF
Introduction to cython: example of GCoptimization
PPTX
Introduction to FPGAs
Loops (1)
Algorithm cup 2010
C coroutine
Q4.11: NEON Intrinsics
Certifying (RISC) Machine Code Safe from Aliasing (OpenCert 2013)
Satellite link-budget-analysis-matlab-code
Compilation of COSMO for GPU using LLVM
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
Python with a SWIG of c++
Scaling FastAGI Applications with Go
Concurrency in Python4k
PHP in 2018 - Q1 - AFUP Limoges
Pythonによるカスタム可能な高位設計技術 (Design Solution Forum 2016@新横浜)
Array using recursion
Q4.11: Using GCC Auto-Vectorizer
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
PREDICTING THE TIME OF OBLIVIOUS PROGRAMS. Euromicro 2001
Introduction to cython: example of GCoptimization
Introduction to FPGAs
Ad

Viewers also liked (20)

PDF
No Lusers Volumen II
PDF
Res Conv Jae Tec 2008
PDF
AuditoríA Wireless con WifiWay
PDF
No Lusers Volumen II
PDF
Jornada Seguridad Digital en Navarra: Noticia y entrevista a Chema Alonso
PDF
Guía de uso de Latch en la UNIR
PDF
Modelado de amenazas en el contexto de la indexación de páginas y propuesta d...
PDF
LDAP Injection Techniques
PDF
X Forum AUSAPE 2014
PDF
LDAP Injection & Blind LDAP Injection in Web Applications
DOC
Living in the Jungle: Legitimate users in Legitimate Insecure Wireless Networks
PDF
Owning bad guys {and mafia} with javascript botnets
PDF
Time-Based Blind SQL Injection Using Heavy Queries
PDF
Web Browser Fingerprinting
PDF
Foca API v0.1
PDF
JTRIG (Joint Threat Research Intelligence Group) Spying Tools
PPTX
WPM: Wordpress IN Paranoid MODE
PDF
Latch en Linux (Ubuntu): El cerrojo digital
PDF
Curso Online de Especialización en Seguridad Informática para la Ciberdefensa
PDF
Connection String Parameter Pollution Attacks
No Lusers Volumen II
Res Conv Jae Tec 2008
AuditoríA Wireless con WifiWay
No Lusers Volumen II
Jornada Seguridad Digital en Navarra: Noticia y entrevista a Chema Alonso
Guía de uso de Latch en la UNIR
Modelado de amenazas en el contexto de la indexación de páginas y propuesta d...
LDAP Injection Techniques
X Forum AUSAPE 2014
LDAP Injection & Blind LDAP Injection in Web Applications
Living in the Jungle: Legitimate users in Legitimate Insecure Wireless Networks
Owning bad guys {and mafia} with javascript botnets
Time-Based Blind SQL Injection Using Heavy Queries
Web Browser Fingerprinting
Foca API v0.1
JTRIG (Joint Threat Research Intelligence Group) Spying Tools
WPM: Wordpress IN Paranoid MODE
Latch en Linux (Ubuntu): El cerrojo digital
Curso Online de Especialización en Seguridad Informática para la Ciberdefensa
Connection String Parameter Pollution Attacks
Ad

More from Chema Alonso (20)

PPTX
CyberCamp 2015: Low Hanging Fruit
PDF
Índice Pentesting con Kali 2.0
PDF
Configurar y utilizar Latch en Magento
PPTX
Cazando Cibercriminales con: OSINT + Cloud Computing + Big Data
PDF
New Paradigms of Digital Identity: Authentication & Authorization as a Servic...
PDF
CritoReto 4: Buscando una aguja en un pajar
PDF
Dorking & Pentesting with Tacyt
PDF
Pentesting con PowerShell: Libro de 0xWord
PDF
Recuperar dispositivos de sonido en Windows Vista y Windows 7
PPTX
It's a Kind of Magic
PPTX
Ingenieros y hackers
PDF
Cuarta Edición del Curso Online de Especialización en Seguridad Informática p...
PDF
Auditoría de TrueCrypt: Informe final fase II
PPTX
El juego es el mismo
PDF
El Hardware en Apple ¿Es tan bueno?
PDF
Hacking con Python
PPTX
Shuabang Botnet
PPTX
Tu iPhone es tan (in)seguro como tu Windows
PPTX
Codemotion ES 2014: Love Always Takes Care & Humility
PDF
Analizando la efectividad de ataques de correlación pasivos en la red de ano...
CyberCamp 2015: Low Hanging Fruit
Índice Pentesting con Kali 2.0
Configurar y utilizar Latch en Magento
Cazando Cibercriminales con: OSINT + Cloud Computing + Big Data
New Paradigms of Digital Identity: Authentication & Authorization as a Servic...
CritoReto 4: Buscando una aguja en un pajar
Dorking & Pentesting with Tacyt
Pentesting con PowerShell: Libro de 0xWord
Recuperar dispositivos de sonido en Windows Vista y Windows 7
It's a Kind of Magic
Ingenieros y hackers
Cuarta Edición del Curso Online de Especialización en Seguridad Informática p...
Auditoría de TrueCrypt: Informe final fase II
El juego es el mismo
El Hardware en Apple ¿Es tan bueno?
Hacking con Python
Shuabang Botnet
Tu iPhone es tan (in)seguro como tu Windows
Codemotion ES 2014: Love Always Takes Care & Humility
Analizando la efectividad de ataques de correlación pasivos en la red de ano...

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

  • 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)