Here is my team's design for a Christmas mini golf fundraising event. Completed over a few very late nights (although the wood working was done a bit earlier). We put a lot of volunteer hours into it and I'm very happy with how it turned out. Tons of fun to build and strangely satisfying to watch it run totally automated ball after ball...
Putt... zzzzzz... bonk, bonk.... BOOM!
HOW TO BUILD IT
The video above gives a good idea of how it all works together and I've written up some more details below for people interested in going further. Remember that you can pause the video at the explanation points to give you more time to read. Enjoy!
Build Difficulty: moderate
Tackling one item at a time is definitely within the reach of a beginner, but putting the whole thing together can be difficult. If you aren't trained in how to handle household AC voltages and wiring safely, please skip that part or work under the supervision of someone that is.
2 x magnetic reed switches
These switches close when a strong enough magnetic field is close by. I use this to sense when the elevator reaches the top and bottom. Make sure you get the ones that are sealed in plastic as the glass only ones break very easily (I'm told).
20 x Neodymium Disc Magnets (8mm x 1mm)
These magnets are mounted on the elevator to trip the top and bottom reed switches. Because these magnets come in discs, you can simply keep adding or removing discs until they trip your reed switch at the ideal location. Be careful handling them. I've seen them shatter when they snapped out of my hands to the bigger group of magnets. Eye protection wouldn't hurt. Purchased on ebay.
Dual H Bridge Motor Control Module
This motor controller module is based on the L298N IC and allows the elevator to go up and down. It is very easy to use and is readily available for cheap on ebay. It is controlled with 2 pins from the Arduino and powered by a +12V power supply (in my case).
5V Relay Module
This common ebay relay module simply applies power to the Shop-Vac Cannon when it is ball-boom-boom time! It is controlled by a single pin on an Arduino. Make sure you get the 5V module version, otherwise you will not be able to control it directly from the Arduino UNO which runs on 5V. BE CAREFUL with the 120V wiring! Use at your own risk. Please treat it with care and be sure to switch the HOT wire like you would with a light switch. Relay's aren't an ideal solution for switching inductive loads like the motor in a shop vac because of the sparks created when turning off. These sparks will wear out your relay contacts faster, and may generate electrical noise into nearby circuits. A simple relay was all that I had on hand for the quick hack and I wasn't using it very long or pushing it hard - it worked just fine. Also be warned that many ebay optocoupler isolated relay modules don't offer true isolation because they share a common ground.
2 x ( Infrared TSOP4838 Sensors + 470Ω resistor + 1 uF capacitor )
These sensors output a low signal when they are hit by the infrared trip wire beam. When the golf ball breaks the beam, the sensor outputs a high signal that the Arduino can detect. One sensor looks for golf balls entering the elevator and another looks for golf balls entering the shop vac cannon. Follow the "application circuit" in the datasheet for wiring details. Each sensor requires a single Arduino pin for sensing.
2 x ( Infrared emitter + 100-1000Ω resistor) + a single NPN transistor + 1kΩ resistor
You have to drive the infrared (IR) emitters (LEDs) at 38 KHz for them to work with the TSOP4838 sensors above. Luckily, this isn't hard. Simply connect the 38 kHz PWM output to the base of a NPN transistor with a 1kΩ resistor. Wire up the LEDs as shown in the video above with each one having a current limiting resistor and them both connected to the Collector pin of the NPN transistor. You may have to experiment with the value of the current limiting resistor depending on your setup (distance and ambient interfering light). Try values between 100 and 1000Ω. Too bright, and reflections of the infrared light might be able to bounce around the golf ball and still trigger the sensor. Too dark and ambient light may cause a lot of problems. You can also experiment with different LEDs and different view angles which is essentially how tightly focused the beam is. Too tightly focused and it is hard to keep aimed properly; too wide and the light may find its way around the ball or not be strong enough.
Be aware of how much current you are using with your IR LEDs and the max of your transistor. Try to keep it around half or less of the transistors' rated current value so that you don't have to worry about heat issues. If you want to use more LEDs, look at using a transistor with a higher "continuous collector current" or look at other switching technologies (MOSFETs).
SparkFun has a good good diagram (and tutorial) of how your IR LEDs, resistors, and transistor will look.
Frequently Asked Questions
Why does the shop vac cannon seem to fire a lot?
Not entirely sure, but it is correlated with movement of the motor. Could be electrical noise, but I have a feeling that the motor is trying to draw more current than power supply can handle (about 2 Amps) and that is causing problems.
How did I get "+N POL-ELF-CARL" on my phone?
That is the only special effect used in the video. I used Blender to motion track the phone and then added in the new number to follow along. Why? Because it was a friend's phone number that would have been shown normally and I didn't want to put it up on the interwebs.
Why use Java at all?
An Arduino is more than capable of interfacing with the sensors and outputs, but I had initially intended to have a lot more activity going on with the elves and so it made sense to move the majority of the program logic up into a higher level language where I could easily customize things (multiple state machines, timers, threads...).
What would I do differently next time?
Bring in a stronger power source (or at least a separate power supply for noisy hungry circuits). Either screw terminal everything or make a PCB. So many loose wires (loose fitting 24 gauge) in breadboards. Definitely make a PCB for the TSOP4838 sensors so that I could have their power filtering much closer. More relays! More motors! Invest in a better real time reliable protocol link between the PC and Arduino. I noticed a number of lost packets and I was only running at 9600 baud. Strange.
It really isn't that complicated once you get started. Just a bunch of details wiring it all up and then trouble shooting sensors and connections. I have other projects I'm looking to open source first. I will be putting up some useful snippets though: IR PWM