arduion and motion sensing

Hi,
I am new to this forum so apologies if this is in the wrong section etc.
I am about to start a project creating a sort of interactive basketball hoop.
At the moment i am just trying to achieve simple steps. The first step is to try and get the hoop recognising when something has passed through it.
Can anyone recommend any sensors that might be fit for this purpose?
Is arduino a good platform for this purpose?
I also at some point in the future want to collect and store data, i was thinking of linking it up with a raspberry pi?
Can anyone also recommend a sensor fit for sensing human beings?
And a sensor good for figuring out distances?
Also what arduino is the best for this?

I know these questions are extremely open, but I am just exploring the early stages of my design, so any help is appreciated.
A little about my background:
I know absolutely nothing about arduino, i've never really ventured into hardware before.
I have computer science degree, I program mainly in C and Java.
Despite not having used arduino before I am excited to begin this journey.

Thanks a lot for any help you can offer it is greatly appreciated.
C_BREEEZ

If you have the capability to mount the IR leds and photo-transistors on the BOTTOM of the hoop and align them then the rest is straight forward. You have to know how to calibrate them. Once they're mounted and calibrated then you need to transmit the data via serial .

FYI,
My grandson has a basketball game with this capability + score-board.

Alright, welcome to the forums. First step is to get an Arduino and do some of the getting started projects to start familiarizing yourself with the programming and the hardware concepts.

For the hoop sensor, I'd probably use an IR emitter and an IR detector on opposite sides of the rim. When the basketball goes through the hoop rim, the IR light is blocked from the IR detector by the basketball, and you can sense this from the Arduino.

You haven't said what you want to happen when the ball goes through. Is there a score board display that you want to show the score on? Do you want to play sound effects maybe from an MP3 module?

What do you mean by sensing humans? Not sure what you are trying to do or accomplish. What are the distance sensors for?

Hi,
seems feasible, but you would have to come up with a mechanical sensor like this: Hoop Tracker Tech Specs

When the ball goes through the hoop it lowers the lever that triggers a micro-switch. The micro-switch closing (with proper de-bouncing) is recognised by the Arduino. With that information you can keep the score (with an extra button you can tell the system if it was a 3 points) or do something else.

I was also thinking if there is a possible solution using an ultrasound sensor (http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor) but I guess it would be difficult due to the speed of the ball and possible false positive because of the shooters jumping in front of the hoop.

Good luck with your project and much fun learning Arduino! :slight_smile:

Sure. Why not. clearly it works.

raschemmel:
If you have the capability to mount the IR leds and photo-transistors on the BOTTOM of the hoop and align them then the rest is straight forward. You have to know how to calibrate them. Once they're mounted and calibrated then you need to transmit the data via serial .

FYI,
My grandson has a basketball game with this capability + score-board.

Hi thanks a lot for the reply, did you see my other post? I deleted it because it wasn't clear who I was replying to, so i thought id use the quote function instead.
I think the IR thing, sounds like a good idea, im going to look on the web for kits to pick up. Essentially im trying to create my own home-brew of what you say your grand son. Sort of my own arcade basketball machine.
Im interested in the distance sensors so I can set my self challenges to see how far I can shoot from and my differentiate between 2pts and 3pts. Obviously all shots would have to be taken from directly in front of the hoop.

Thanks a lot for your input and interest, il update this thread as I move on

Xpendable:
Alright, welcome to the forums. First step is to get an Arduino and do some of the getting started projects to start familiarizing yourself with the programming and the hardware concepts.

For the hoop sensor, I'd probably use an IR emitter and an IR detector on opposite sides of the rim. When the basketball goes through the hoop rim, the IR light is blocked from the IR detector by the basketball, and you can sense this from the Arduino.

You haven't said what you want to happen when the ball goes through. Is there a score board display that you want to show the score on? Do you want to play sound effects maybe from an MP3 module?

What do you mean by sensing humans? Not sure what you are trying to do or accomplish. What are the distance sensors for?

Hi, thanks for the reply and interest, it is greatly appreciated.

I think the IR sensors are a great suggestion, im going to look online for them in kits.

Essentially, I want a scoreboard in my first iteration. But later I want to add in users, so friends, family etc can log into the machine and record overall scores and achievements seperately. (im guessing id use a raspberry pi with a database on it, that keeps track of stats for each user, probably write a bit of software that handles log ins etc and updates the data and displays it on a monitor. The idea is really half baked so if u can think of better suggestions feel free. Or if you think anything may not work) This is a more advanced dream. Im going to get the basic functionally going first and add on.
Ultimately Id like to make it as interactive as possible, like your suggestion, playing sound effects for scored baskets etc.

Im interested in detecting humans, so it might play some tunes as you walk by to try and suck you into playing. It will be annoying but fun. I guess im looking at some sort of burglar sensor there?

And the distance sensors are for measuring where the shot was taken from. Although, how im going to do this is quite half baked.

Thanks again for your contribution!

Marco_Ghislanzoni:
Hi,
seems feasible, but you would have to come up with a mechanical sensor like this: Hoop Tracker Tech Specs

When the ball goes through the hoop it lowers the lever that triggers a micro-switch. The micro-switch closing (with proper de-bouncing) is recognised by the Arduino. With that information you can keep the score (with an extra button you can tell the system if it was a 3 points) or do something else.

I was also thinking if there is a possible solution using an ultrasound sensor (http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor) but I guess it would be difficult due to the speed of the ball and possible false positive because of the shooters jumping in front of the hoop.

Good luck with your project and much fun learning Arduino! :slight_smile:

Hi thanks for the reply, these ideas are getting me excited for starting out!

That hoop tracker is clever, i like the fact it uses an accelerometer to detect misses, i didn't think of that at all.

And thanks for the link to that tutorial. I think im going to spend the next few days reading into these things and absorbing as much info as possible. And ordering my first arduino and practicing running basic things on it.

Thanks again for the help and ideas.
Should be fun!

Xpendable:
First step is to get an Arduino and do some of the getting started projects to start familiarizing yourself with the programming and the hardware concepts.

Just getting onto this now, should be fun :slight_smile:

Also is there a particular arduino that you might recommend for this project?? I guess im looking at something that can handle a few sensors at once? I also plan to keep adding functionality as I go, so i guess something with a bit of room for everything I need.

raschemmel:
If you have the capability to mount the IR leds and photo-transistors on the BOTTOM of the hoop and align them then the rest is straight forward. You have to know how to calibrate them. Once they're mounted and calibrated then you need to transmit the data via serial .

FYI,
My grandson has a basketball game with this capability + score-board.

Im just trying to figure out my design at the moment.
Im a bit worried that if I mount on the hoop and the ball hits the rim but doesnt go in, the rattle may create a false positive.
I cant figure out how the arcade style ones work. Seems they just have 2 black blocks, one above and one below the rim

Thanks for any help,
Also do u know of any good parts for motion detection?
Thanks again

The vibration of the hoop will have no effect on properly mounted and calibrated IR sensors.
What you need to focus on is designing a way to mount them that allows for calibration.

raschemmel:
The vibration of the hoop will have no effect on properly mounted and calibrated IR sensors.
What you need to focus on is designing a way to mount them that allows for calibration.

Ok awesome, i was just worried that if it moved it might cause the IR beams to miss their targets.
Just looking at creating the adjustable mount now, trying to think of something that, that can be adjusted with screws perhaps, a few that when turned adjust the angle and a few more that adjust its horizontal and vertical position.

Thanks again for the help

i was just worried that if it moved it might cause the IR beams to miss their targets.

If the transmitters and receivers are aligned, when the hoop moves (vibrates) both Tx and Rx move together.

cool, sounds good.
Thanks

Hi,
I have a pair of these https://www.sparkfun.com/products/241, just trying to set up a circuit to test them on my uno and breadboard.
Im unsure what resistors to use etc.
Is there any sure way to find out?
Thanks

The page you linked has a useful schematic, but is incorrectly titled.
http://www.reconnsworld.com/ir_ultrasonic_basicirdetectemit.html

AWOL:
The page you linked has a useful schematic, but is incorrectly titled.
http://www.reconnsworld.com/ir_ultrasonic_basicirdetectemit.html

cheers man, that worked :slight_smile:

The schematic link is on the same page
http://www.reconnsworld.com/ir_ultrasonic_basicirdetectemit.html
You can see the photo transistor has a pullup resistor.
Look closely at the diagram.
See the line labeled "Baffle " ?
the two devices, the led (the dark colored one) and the photo resistor (light colored one) should be side by side on a tiny pcb.
You can cut down a Radio shack proto board to 1/4" square . Mount the two side by side.
Put an opaque tube over them , just large enough to fit over them. If you don't have any material to use then a large straw painted with black paint on the outside and cut down to 1/2 " to 3/4" long will do.
Next you need to insert a thin strip of plastic painted black on both sides in between the led and the photo resistor . This is the baffle. The baffle has to block light. The IR light from the led should emit from the tube without being detected by the photo resistor unless there is a reflective surface in front of the tube. When an object is placed in front of the led , the IR beam (I don;t want to call it light because it is invisable) bounces off the object and back into the other side of the tube to be detected by the photo-resistor which turns on pulling the OUTPUT LOW. This should tell you that you code should expect a LOW when an object is present and HIGH when there is no object in front of the tube. When you complete the construction, you test it by verifying that the output is HIGH with NO object and LOW with an object in front of the tube.
Obviously, the blacker the paint , the better. When you insert the baffle, glue it in with superglue. (one drop only)

Have you just gone from beam interrupt to IR reflect?
Because beam interrupt only needs a separated light source and limited aperture sensor.

Breeez, don't be so quick to start buying parts and framing your code. Not until you have tried and checked around a whole lot more.

How is your physics?
If the hoop vibrates and the IR sensor is 4mm in diameter, is there any way that light from one side of the hoop can miss that sensor? Light that will cross that hoop in less than 2/1000ths of a microsecond?

Look around at all the sensing options before deciding. People tend to commit to what they spend money/time on. You can paint yourself into a corner before you really start.

What do you know about electronics? Even the basics as taught in physics?
A cheap AVR chip and beam interrupt setup will "see" the ball many many many times even when stuffed through the hoop hard. Digital read data and processing at 20KHz is not a big deal.

What do you know about small environment code? An UNO has 32K flash for code and constants/tables but only 2K for both heap and stack. Dynamic allocation practices will severely limit how many objects you can use. Recursive code has to be avoided or tightly controlled. You may get away with some examples but then try adding a library that uses a buffer and see what you get.
Doing text work, stick with C string arrays and avoid C++ String Objects not just for space but also for the clock cycle overhead as well. You can use them but they reduce what else you can do.

What do you know about event driven code that doesn't rely on an OS? How about state machines?
There are tutorials and examples for that, it's what microcontrollers are made to do going back to the 70's.

Spend real time on small examples and making each piece you think to use work on its own before making any final decision to include it. Not only do you need working pieces but they have to fit together in that tiny chip.

Which Arduino? With an UNO you can program any of many AVR chips to run stand-alone. Want 16K RAM? Got it.
Which Arduino? There are what I call Frankenduinos like the Due, the Yun and the Galileo if you want to spend more money that you probably don't begin to need to. But heck, you can get a SAM3X board for less than $20.

Really, take time now to learn and see. You're not in Kansas anymore.

raschemmel:
The schematic link is on the same page
http://www.reconnsworld.com/ir_ultrasonic_basicirdetectemit.html
You can see the photo transistor has a pullup resistor.
Look closely at the diagram.
See the line labeled "Baffle " ?
the two devices, the led (the dark colored one) and the photo resistor (light colored one) should be side by side on a tiny pcb.
You can cut down a Radio shack proto board to 1/4" square . Mount the two side by side.
Put an opaque tube over them , just large enough to fit over them. If you don't have any material to use then a large straw painted with black paint on the outside and cut down to 1/2 " to 3/4" long will do.
Next you need to insert a thin strip of plastic painted black on both sides in between the led and the photo resistor . This is the baffle. The baffle has to block light. The IR light from the led should emit from the tube without being detected by the photo resistor unless there is a reflective surface in front of the tube. When an object is placed in front of the led , the IR beam (I don;t want to call it light because it is invisable) bounces off the object and back into the other side of the tube to be detected by the photo-resistor which turns on pulling the OUTPUT LOW. This should tell you that you code should expect a LOW when an object is present and HIGH when there is no object in front of the tube. When you complete the construction, you test it by verifying that the output is HIGH with NO object and LOW with an object in front of the tube.
Obviously, the blacker the paint , the better. When you insert the baffle, glue it in with superglue. (one drop only)

Awesome, I didn't actually think of this approach. I have a working circuit, but i am just firing the beam from the emitter into the detector. I have it set up that when I break the beam by putting my finger between the two components it plays a sound out of a little speaker. I just sort of set this up to see how they worked. It reads like 900 through serial when they are blocked and 30 through serial when the beam is hitting.
I guess this was why I was so worried about hoop vibration and you thought it wouldn't be a problem. Because I was thinking of mounting emitter on one side and detector on the other, so they would move. I see in this approach this wouldnt be an issue and they are both on the same side. Its a clever way of doing it.
Im spending my saturday watching lectures on electronics, i think next lecture is resistors, so hopefully soon Il have a better understanding. Going to google a pullup resistor to find out what that is.
Once again thanks for the help, it is greatly appreciated. the project probably wouldn't be moving without your input :slight_smile: