Things used in this project

Schematics

Green Circuit
This is the schematic for connecting one of the LEDs to a Raspberry Pi GPIO. This applies to Red and Blue and go to different GPIOs in the Raspberry Pi.
Ledsonairsign schem afedrpphdj

Code

OnAirSign.pyPython
This is the script that should be running in the Raspberry Pi all the time for the On Air Sign to work.
It loops through all the Pi Cap's pins and checks which pin was touched. If a pin is touched, the turnColor function is called as passes the combination to turn on the specified color. Depending on the pin that is touched, the raspberry pi tweets a selected message. I've added a time stamp to each tweet because Twitter won't allow duplicate Tweets.
import RPi.GPIO as GPIO
import time
from twython import Twython
import signal, sys, MPR121
import datetime

now = datetime.datetime.now()

sensor = MPR121.begin()
touch_threshold = 40
release_threshold = 20
sensor.set_touch_threshold(touch_threshold)
sensor.set_release_threshold(release_threshold)

from auth import (
    consumer_key,
    consumer_secret,
    access_token,
    access_token_secret
)

twitter = Twython(
    consumer_key,
    consumer_secret,
    access_token,
    access_token_secret
)

#GPIO pin numbers
red = 12
green = 13
blue = 15

GPIO.setmode(GPIO.BOARD)
GPIO.setup(red, GPIO.OUT)
GPIO.setup(green, GPIO.OUT)
GPIO.setup(blue, GPIO.OUT)

def turnColor(R,G,B):
	if R == True:
		GPIO.output(red, GPIO.HIGH)
	else: 
        GPIO.output(red, GPIO.LOW)
	if G == True:
	    GPIO.output(green, GPIO.HIGH)
	else: 
	    GPIO.output(green, GPIO.LOW)
	if B == True:
	    GPIO.output(blue, GPIO.HIGH)
	else:
	    GPIO.output(blue, GPIO.LOW)

while True:
	if sensor.touch_status_changed():
		sensor.update_touch_data()
		#Loop trough the PiCap's pins
		for i in range(12):
			if sensor.is_new_touch(i):
				if i == 1:
					#Neutral State: White LEDs
					turnColor(True,True,True)	
				elif i == 3:
					#Started Filming State: Blue LEDs
					turnColor(False,False,True)	
					message = "I started filming a new video! Woooooo! #newvideosoon" + now.strftime("%H:%M:%S")
					twitter.update_status(status=message)
					print("Tweeted: %s" % message)
				elif i == 5:
					#Stuck State: Red LEDs
					turnColor(True,False, False)
					message = "I am stuck. Prototype down. Still filming though.. #debugging #newvideosoon" + now.strftime("%H:%M:%S")
					twitter.update_status(status=message)
					print("Tweeted: %s" % message)
				elif i == 7:
					#Eating State: Purple LEDs
					turnColor(True,True,False)
					message = "Pizza time #filmingfood"
					twitter.update_status(status=message)
					print("Tweeted: %s" % message)
				elif i == 9:
					#Done Filming State: Green LEDs
					turnColor(False,True, False)
					message = "I am done filming. Woooooo! #editingtime #newvideosoon" + now.strftime("%H:%M:%S")
					twitter.update_status(status=message)
					print("Tweeted: %s" % message)
				else:
					#Neutral State: White LEDs  
					turnColor(True, True, True)

Credits

Img 6261 91ryknwnh9
Estefannie Explains It All
0 projects • 56 followers
I make things in my kitchen and put it on YouTube. Sometimes I also make computer science tutorials.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog