2016
04.01

I’ve been looking for things to do with my older Pi’s since purchasing the Pi 3 last month and I have been leaning back towards the Pi’s roots of quirky electronics projects. I bought a Pi camera a few weeks back and was considering making a portable PiCam and I also wanted to make a Remote goal light for hockey games.

I decided to actually combine the two ideas into 1. I am going to make an NHL Goal light that takes goal reaction pictures with the Pi camera.

First trials

Initially I wanted to see if I could set off the light I had with my Pi. The light takes a 3V disc battery, the Pi can output 3.3V over GPIO. What I did was I took a pair of Jumper cables and lobbed off the one end and stripped it a bit and plugged the other end into a GPIO pin and a GND pin. I took the stripped ends and put them on the +/- where the battery would go and pressed the button while the pin was set HIGH. Voila it can work in the basic sense and it didn’t blow up the light.

Converting the bottle opener

I tinned the stripped cable and then soldered it to the positions on the contacts for a permanent connection.

Then I cut up some small cardboard pieces about 1mm thick. The light originally worked by setting off 1 or more of 3 buttons on the light that pressure from using the bottle opener would cause. With the pieces of cardboard over the small buttons I put the bottle opener piece back into the light and locked it into place over the cardboard. This keeps the buttons permanently pressed down so when I set the GPIO pin HIGH it activates the light.

Python script

I created a python script that activated the pin, waited 10 seconds then pulled it down

#!/usr/bin/python
import RPi.GPIO as GPIO              
from time import sleep               
GPIO.setmode(GPIO.BCM)               
GPIO.setup(15, GPIO.OUT)              
    
GPIO.output(15, 1)      
sleep(10)                  # run horn 10 seconds  
GPIO.output(15, 0) 
GPIO.cleanup()             # resets all GPIO ports used by this program  

 

Remote control

What I did for the remote control was installed a web server on the Pi and created a script to execute the code above. Now I know you can run python within apache I have seen the lengthy guides but I like the fast route so I did PHP for the web side of the scripting.

apt-get install apache2
apt-get install php5

 

After it was installed I whipped up a quick script to execute the python but I got an error that you should be root to access the GPIO. I changed the Default USER/GROUP of Apache to PI. Since this is a single purpose local network project that didn’t seem to big of a deal to me however if you use whatever device you do this to for more than just that I wouldn’t recommend it. If you ran actual web pages along with it and it was somehow compromised what I did there in essence gives the attacker “pi” user privilages. Figured I should spell that out before continuing.

Simple webpage to activate horn

I wrote a simple web page that has an image of a goal horn. Click the image and the horn goes off. The website can only be accessed within my local home network. I also set an icon for the site so that when I save the bookmark to my mobile phone it looks like an App icon.

<html>
	<link rel="apple-touch-icon" href="goal.jpg" />
	<body>
		<a href="/?goal=1" border=0><img src="goal.png"/></a>
<?php
	if(isset($_GET["goal"])) {
		exec("./webhorn.py");
	}	
?>
	</body>
</html>

 

Next plans

So now that I have upgraded the horn from bottle opener to remote horn the next plan is to make it do automatic goal horning for which team I tell it. I also plan to add the ability to play a louder horn audio file through the audio out and also incorporate the Raspberry Pi camera to take goal reaction shots. Stay tuned for more!

Facebook Comments

No Comment.

Add Your Comment

You must be logged in to post a comment.