bg762
Posts: 5
Joined: Wed Oct 03, 2012 7:19 pm

RPI Relays for Goal Lights

Thu Jan 10, 2019 5:40 pm

RPI Goal Lights.png
RPI Goal Light Example
RPI Goal Lights.png (57.9 KiB) Viewed 540 times
Hello,

I am looking for programming advice.

I am assuming Python may be the easiest since I am new to this a bit.

I am looking for a way to program the RPI GPIO to control a set of goal lights.

There will be two lights (Left and Right) which will be triggered via two GPI's on the RPI.
Each of the two relay outputs will be tied to their respective GPI.

When a GPI is pressed the corresponding relay is to fire and hold closed for 20 seconds.
While the relay is being held closed additional button presses are to ignored as to not restart the initial timer.

After the 20 seconds have passed the output relays can be triggered once again.

I have attached a small image illustrating the setup.


If anyone has advice or even better a small programming example to accomplish this it would be greatly appreciated.
Trying to get a few things upgraded for our local sporting arena.

PhatFil
Posts: 1197
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: RPI Relays for Goal Lights

Thu Jan 10, 2019 5:58 pm

https://www.raspberrypi.org/documentati ... /README.md
pretty much covers it, replace the led in the circuit for your relay
copy and paste the code for a 2nd relay/button, edit to point to the correct gpio pins and extend the sleep period
should get you most of the way,, .
what are goal lights? is someone playing ultra cricket??

bg762
Posts: 5
Joined: Wed Oct 03, 2012 7:19 pm

Re: RPI Relays for Goal Lights

Thu Jan 10, 2019 7:16 pm

Hockey goal lighting.

The main thing is not re-triggering the timer if the GPI goes high again while the light is already on.

Will be wired to a DPDT switch along with a horn.
The horn button could be pressed multiple times. We don't want the 20 second timer to restart if the button is pressed 3 times within 20 seconds. Just act on the first and ignore all other presses till the 20 second light on phase is complete.

PhatFil
Posts: 1197
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: RPI Relays for Goal Lights

Thu Jan 10, 2019 9:40 pm

hockey eh? not suprising i didnt twig..

if you use the sleep command like in the blinking led example linked to but extend the period to 20 seconds then the program will 'sleep for those 20 seconds ignoring any other input. usually folk want to also be able to respond to other inputs so the no-delay blink example gets wheeled out as it uses time counts and is a little more complex..

If you can get a breadboard led, button and resistors together and make a mock up of your system design substituting the led for a relay you can test your code for both function and robustness before committing..

Rather than using relays directly with your pi it may be expedient to use a relay modules. (relay and supporting circuitry on a pcb) the 3.3v ogic level of the pi may not be sufficient to drive the coil of a 5v or 12v switched relay.. and my limited understanding is there is also some risk from electrical feedback from a relay on release.

Return to “General programming discussion”