Go Down

Topic: Using LDR for Scoring System in a DIY Air Hockey (Read 487 times) previous topic - next topic


Good Day everyone! So our class was divided into groups and each group was to make a game with the theme "Let's Have Fun." Our group decided to make a Air Hockey  and the problem was that we don't know where to start fornthe code since we should use a Transducer for the project.

We had the idea of having a laser pointing  at the LDR at the goal and that everytime the 'disc' passes through, the laser will be cut. And that every cut of the laser the score should add 1. I still have no idea about the code since me and my groupmates are total beginners.

We use LEDs as a the display for the score. Example: when player 1 scores, 1 LED lights up and if he/she scores again, 2 LEDs light up.

Hoping for a solution or at least an idea for the code. Thanks!  :)


LDRs are too slow for this (they need >0.1 seconds to really detect something, by when the puck is long gone). Use a proper break beam sensor instead. Connect it to a digital pin and read it just like a push button.
As the time the puck spends is short, you may need an interrupt, but it depends also on the rest of your sketch. If checking the two sensors (one on each side of the table) is all it does, no need for that.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Most LDRs are glacially slow, some are quicker (but less sensitive, its a trade off).  All photodiodes and
phototransistors are plenty fast enough.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


I did this same project a few years ago.  Never finished the puck return(puck kept getting stuck), but did finish the scoring system with an arduino.  Simple beam break with an IR LED and TSOP ir receiver worked great.  Instead of just lighting LEDs for score, you can count up in BCD and drive a 2 7 segment displays.  You will only need 3 pins to drive each 7 segment display utilizing a bcd to 7 segment decoder, assuming you only need to count to 7.  If you need to use a transducer, and are set on using an LDR, you can possibly count the score when the puck comes to rest and add a high delay after.  You can use analogread on a pin, and count a score at a certain threshold.  You will need to find the threshold with trial and error.  Same could be done with a phototransistor like stated above, and it should be quicker.  Again, you will need to use trial an error to get a value that works and isn't triggered by ambient light.

Good luck


Typically air hockey goal sensors are impact switches at the back of the goal pocket.
What, I need to say something else too?

Go Up