Intro: Arduino Controlled Home Run Derby
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)
- 20 x 4 LCD
- Potentiometer with knob
- 3 buttons
- on/off switch
- wire wrap for controller cord
- Arduino Uno
- 2 small breadboards with detachable power rails
- HiTech hs311 servo
- Spline to shaft coupler
- A lot of wires
- 3d printer
Step 1: Setting Up the Circuit.
Before putting the project together you're going to want to get the circuit assembled and make sure it is working properly.
The 4 rows of lights in groups of three are charlieplexed and require the charlieplex library from the arduino playground. This method uses only 4 pins to control 12 lights. The resistors came with the LEDs and have a resistance of 200 ohms. The LED in the Pitchers mound is in the upper left hand corner of the breadboard. The one below it would be the next to light up.
The single light to the right of the other LEDs goes in the center of homeplate. While this light is on pin A0 reads the photoresistor value and does a comparator operation to determine if there was a hit or not.
Step 2: The Code
I used two tabs for the code to keep it organized. The backend has functions I created to run on the main tab and keep it looking clean. The code continuosly reads the potentiometer and adjusts the servo accordingly using the servoControl() function on the backend of the code. This is also used as a timing mechanism to time the lights on the different pitches.
pitchStart() is where the magic happens. This block of code contains the pitch sequence and also determines if there is a hit or not from the photoresistor analogRead value when the non-charliplexed LED is HIGH. The value used in the comparison needs to be adjusted according to the lighting of where it is going to operate.
The code uses two external libraries from arduino.cc. the Charliplex library is used for the LEDs and the liquid crystal is used to control the display.
Step 3: Assembling the Game
Download and print the part files to begin assembly.
Everything fits pretty tight and there is a little bit of sanding required but all the parts will fit beautifully when finally assembled. I would recommend using as short of wires as possible to assemble this, there isn't much room in the box and the less you have in the way the better.
Attach one breadboard directly to the underneath side of the lid. This breadboard controls everything on the lid; the charliplexed lights, the hitLed and the photoresistor. The other bread board has the controls and is kind of tricky to get together but I found a dab of glue to hold the wires on the potentiometer in place helped. A power rail only from a breadboard is used to power everything off the 5V pin of the Arduino.
The scoreboard has wires running down one of its legs. Supports from 3d printing need to be carefully drilled out along the inside of this leg to be able to slip the wires through. I would recommend making the scoreboard taller and wider, it fit but barely.
Use a spline to shaft coupler on the servo and a D-shaft to connect the servo to the bat. I found these at servocity.com.