Page 1 of 1
Will Raspberry do what I need?
Posted: Sun Apr 20, 2014 2:57 am
by Deb E.
Hey guys,
I'm Debbie, and a total newby. I apologize if this question is in the wrong spot, and if so, could you please direct me on where it should be?
My brother is 15, and does NERF gun wars with his friends. He was chatting with me about a thing he wants to build, and when I asked a professor about it, he suggested a Raspberry Pi board as a base. Unfortunately, I haven't been able to follow up with the professor since then.
I know basically nothing about computing, and only a little about electronics, but I DON'T need you guys to design or build this for my brother. I am NOT asking for free work.
All I'm asking is if someone could tell me if Raspberry Pi would be able to do what he wants this cone to be capable of.
The basic idea of the game is that one team has to take "batteries" to 3 different cones and get them all lit at the same time, while the other team tries to shoot the cones to turn them off.
If the second team CAN turn them off, it takes 3 separate members of the first team to turn it back on.
I have a picture that I put together in Google, with a description below it.
Thanks for any help you can offer.
Debbie
https://docs.google.com/presentation/d/ ... slide=id.p
Re: Will Raspberry do what I need?
Posted: Sun Apr 20, 2014 8:40 am
by paddyg
Debbie, the Raspberry Pi would be able to do the computing side but the physical side of your plan is probably the hardest part. I would see issues: 1. the energy of a nerf bullet is very low so quite hard to get targets that would be sensitive enough that don't get triggered by gusts of wind etc. 2. ideally the bases would be quite far apart but would communicate wirelessly which may be tricky, especially in a forest (or other good gaming terrain!) In some ways the simplest method would be to use a standard wifi network with off the self router and dongles but I suspect that won't work and it is overkill for your requirement which is basically relaying if a cone is on or off. So either you don't connect the cones together - in which case you don't really need to use anything more complicated that switches, or you use add-on wireless system (search on this forum to see what others have done) or, simplest, use wires.
Re: Will Raspberry do what I need?
Posted: Sun Apr 20, 2014 5:28 pm
by Deb E.
Thank you Paddy,
My brother's idea was that the "thump" of the darts hitting the target could activate an audio switch mounted inside the cone, while anything less than that thump would be too soft. I didn't do the research on that, so I only know what he told me. Apparently there are audio switches that have variable sensitivity.
It seems I wasn't clear in what he wants: No wifi needed, as each cone was intended to be a stand alone item. I honestly don't even know if wifi would be possible, as the cones could be up to 200 yards apart in a forested area. His idea was that players would simply use walkie-talkies to say when a unit was active or not.
As for simple switches: Do they have those that can beep each minute, and will only allow themselves to be triggered once per second? Those seem quite advanced, and are far more complicated than any switches I've ever encountered. That's why we both assumed that a logic circuit of some sort (especially with the QR tags) would be needed.
Re: Will Raspberry do what I need?
Posted: Sun Apr 20, 2014 7:13 pm
by Tarcas
For the "battery" I'd just use a jumper which, when the "battery" is plugged in, connects a wire to ground. The non-ground wire would be connected to a GPIO and through a pull-up resistor to 3.3v. It would work exactly like a switch.
For shooting the cone... sorry, I'm not aware of anything that will work reliably for that. A sound-triggered switch, as you've mentioned perhaps, but I'm not familiar with anything like that so I can't really offer advice there.
As for a switch that can only be triggered once per second and will beep each minute... I'm not sure about that, but you could certainly emulate this behavior by only checking it once per second (or only allowing a state change once per second if you want it to be activated immediately and remain that way for at least one second) and having the Pi itself play a "beep" once per minute as long as the switch is triggered.
Re: Will Raspberry do what I need?
Posted: Fri Apr 25, 2014 3:06 pm
by Deb E.
Could a Pi be easily programed to only perform an action once per second? For example, no matter how often the switch is triggered, the Pi would ignore them for an entire second before checking to see if it was triggered again?
My dad has a friend who does electronics who knows about switches, but doesn't know Pi, and he said he could find a switch that could record the "thumps" of the darts, but that the Pi would need to only check for them once per second. He also said that the Pi would need to be able to use the switch as a trigger to perform another action. An "if...then", I believe he called it.
Re: Will Raspberry do what I need?
Posted: Fri Apr 25, 2014 3:23 pm
by Tarcas
Deb E. wrote:Could a Pi be easily programed to only perform an action once per second? For example, no matter how often the switch is triggered, the Pi would ignore them for an entire second before checking to see if it was triggered again?
My dad has a friend who does electronics who knows about switches, but doesn't know Pi, and he said he could find a switch that could record the "thumps" of the darts, but that the Pi would need to only check for them once per second. He also said that the Pi would need to be able to use the switch as a trigger to perform another action. An "if...then", I believe he called it.
Absolutely. Although implementation depends on how the sensor works. You'd normally just call sleep(1) function to sleep for a second before continuing the loop and checking the sensor again. However, if the sensor may show a trigger for a fraction of a second (doesn't hold its state until reset, and doesn't stay pressed like one may expect from a button) then you might need to check more often (maybe 10 times per second or more) and then act on it if one or more of those readings showed that it was triggered. You can either act immediately and then sleep a second before resuming checking, or you can wait until the second elapses before acting on it. It's all your choice, and how you want to treat your one-second delay will dictate exactly how it is written, but I'll tell you there are several possibilities.
Probably what you want is this (this is pseudocode, and I tried to break it down so a non-coder can understand.)
Code: Select all
Do this forever:
Check sensor
If sensor was triggered then do stuff and then wait 1 second
If sensor was NOT triggered, wait 0.1 second (for 10 readings per second; adjust based on the sensor's output time)
Loop back up to line 1
Re: Will Raspberry do what I need?
Posted: Sat Apr 26, 2014 12:26 am
by ame
This sounds like an interesting and fun project. The Pi could do what you want, or an Arduino.
I recommend that you don't use audio to detect the target hit. It will be prone to false triggering from external noise, and an almost-hit would be registered the same as an actual hit. Instead I suggest you use a "real" switch.
Even before buying a Pi you can experiment with targets and switches. A switch is really just two conductors which touch together. You could try some paperclips, springs, tape and rubber bands with a simple electrical circuit made with a battery and torch bulb. If you can make a target and switch that lights the bulb, even briefly, it could be detected by the Pi.
Since there are three of these in a forest I'd use an Arduino. They are cheaper, and they don't need careful handling for bootup and shutdown.