Skip to content

Instantly share code, notes, and snippets.

@Vontux
Created October 22, 2017 08:09
Show Gist options
  • Save Vontux/db61a8ac7d25cf39d076d3f697161761 to your computer and use it in GitHub Desktop.
Save Vontux/db61a8ac7d25cf39d076d3f697161761 to your computer and use it in GitHub Desktop.
Script to test TTP223 Capacitive Touch Switch
#!/usr/bin/env python
#tweaked a script from an adafruit tutorial
#https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi?view=all
import os
from time import sleep
import random
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN,pull_up_down=GPIO.PUD_UP)
answers = [
"Oh my...",
"keep touching",
"bad touch...I like it",
"oh boy...thats the stuff",
"hey there baby...keep it up",
"Yep...I enjoy this touching greatly human",
"You complete my circuit...",
"The mitochondria is the powerhouse of the cell",
]
while True:
if (GPIO.input(21) == True):
print random.choice(answers)
sleep(0.1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment