Automatic Scoring for the Executive Par 3 Golf Game

by gcall1979 in Circuits > Arduino

4245 Views, 20 Favorites, 0 Comments

Automatic Scoring for the Executive Par 3 Golf Game

Electronic scoring final 3.jpg
Electronic scoring final 4.jpg

I recently posted an Instructable on building a fun putting game that is portable and can be played both inside and outside. It is called “Executive Par 3 Golf Game”. I designed a replica score card to record each players score for 9 “holes”. As in real golf, the lowest score wins.

I got to thinking; what if I could keep track of scores automatically?

Electronically Counting the Golf Ball

IR sensot adafruit.jpg

I needed to find a way to count a rolled golf ball as it fell through a scoring hole. Remember, each hole has a different scoring value, with the “Ace” hole having the lowest point value. I have used Infrared (IR) break-beam sensors on previous games and thought I would incorporate them into this game also. I used a product from Adafruit Industries called a “IR Break Beam Sensor – 3mm LEDs”. The Product ID is 2167:

https://www.adafruit.com/product/2167

They are sold in pairs (emitter & receiver) and offer a simple way to detect motion. They work up to 10 inches apart and can be powered by the Arduino 5V power supply. You can use these with the Arduino built in pull-up resistor, so a separate resister is not needed. The emitter sends out an IR beam and the receiver, directly across from it, is sensitive to this IR light. If something solid passes through the beam (like a golf ball) the beam is broken, and the receiver can be programed to let you know.

Installing the Sensors on the Target Board

Countersink IR Sensors 2.jpg
IR recess under board.jpg
Countersink IR Sensors 5.jpg
Countersink IR Sensors 4.jpg

The putting target board was not attached to the surrounding cabinet. It just sat on 2 ½” corner height spacers so I was able to remove it and flip it over to mount the sensors. I needed to mount the IR sensors on the underside of the plywood play board so they would not interfere with the free-falling of the golf balls. A 1” diameter hole was drilled on opposite sides of each scoring hole to a depth of 3/8 inches. The IR receiver and emitter were placed just inside the rim of the hole so the balls would not hit them. They were mounted permanently with a small wood screw and some epoxy glue, so they were aligned perfectly across from each other.

Wiring the Sensors on the Target Board

Countersink IR Sensors 7.jpg
Countersink IR Sensors 6.jpg

Once the IR sensors were all mounted, they had to be wired together for the common ground and 5V connections. Each output wire (white) had to be extended to the edge of the target board. A 6-wire female connector was attached to each wire to extend out the rear cabinet of the target board assembly. All wiring was tacked down and attached securely against the inside of the game board so as not to interfere with the return of a golf ball once it goes through a scoring hole.

Building the Scoreboard Case

Scoreboard Case 2.jpg
Scoreboard Case 1.jpg
Scoreboard Case 4 with mounting board for electronics 1.jpg
Scoreboard Case 4 with mounting board for electronics 2.jpg
Scoreboard Case 3.jpg
Onoff button 2.jpg

A little bit of woodworking was still needed in this Instructable. A wood rectangular scoreboard case was fabricated from ½” thick plywood. The dimensions of the case are 15 5/8” wide x 9 ¼” high x 4” deep. You can see in the photos the sequence of building this case. A ¼” wide dado groove was placed on the inside of each case side about ¾” in from the same outside edge. This groove will be used to hold the scoreboard graphic placed between two sheets of 0.2 inch thick plexiglass. The last part of the case to be cut is the electronic component mounting board. This board was cut from 1/8” thick plywood and attached to a piece of ¾” pine at a right angle to serve as a base. It will also serve as a means of attachment to the case itself. The board had to be notched to fit in between the small corner bracing pieces.

An On/Off power button would be mounted on the scoreboard case, also. It will be mounted on the outside of the case in a recessed position to protect it from being accidently hit. The on/off switch will be connected in line with a 9-volt DC battery source that powers the Arduino Uno board and all other electronic components of the scoreboard.

Designing the Scoreboard Graphic

Final Layout.jpg

Instead of trying to paint a scoreboard graphic myself, I decided to design one in PowerPoint and cut out windows for the various scoring displays. I wanted the scoreboard to give feedback to the players and display as much information as possible. Included would be:

1. A different color light for the score of the last golf ball putted.

2. A display showing what hole you are playing (1-9).

3. A light that goes on if the 2-player button is pushed.

4. A light goes on for a new game (Reset button was pushed)

5. Two displays for each player’s score.

The final graphic is shown in the attached file. The black rectangles will be cut out for the scoring displays.

Game Input Buttons (Switches) and Case

Game Buttons 1.jpg
Game Buttons 2.jpg
Game Buttons 6 mounted.jpg
Game Buttons 4 output connector on back panel.jpg
Game Buttons 8.jpg

A few buttons were needed to control the flow of the putting game. The three input buttons needed were:

1. Reset or New Game (Green)

2. 1 vs 2-player Game (White)

3. Double Bogey (Out-of-Bounds - Red) – where no IR sensor could be used. A score of 5 would be added to the players score.

I used a standard plastic electronic case to mount the 3 arcade buttons. The case was obtained from Amazon. It measures 7 ½” wide x 4 ¼” tall x 2 3/8” deep. Each arcade button with its attached micro switch will act like a momentary switch. Standard holes that were 1-1/8” diameter were cut in the side of the case and evenly spaced. The buttons were mounted and a small wiring harness was fabricated with the 3 output lines of the micro switches and a common ground line soldered to a small breadboard with a 2.54 mm male pin head connector.

Scoreboard Components

four digit adafruit.jpg
Electrical Part 3.jpg
Electrical Part 7.jpg
Electrical Part 5.jpg
Electrical Part 6.jpg
Distribution Block.jpg
Electrical Part 4.jpg
Electrical Part 1.jpg

The scoreboard components would consist of:

A. Two 4-digit, 7-segment LEDs for each player’s score and a single digit, 7-segment LED would be used to track the “hole” they are playing. The 4-digit, 7-segment LEDs are from Adafruit Industries. They are called “1.2” 4-Digit 7-Segment Display with 12C Backpack – Red”. You need two of these and the Product ID is 1269. See below:

https://www.adafruit.com/product/1269

B. The oversized (1.3”) single digit 7-segment LED was a generic purchase from eBay. Any oversized display will work and must be wired correctly for a common cathode or common anode based 7-segment LED. To simplify the mounting of the display, it was first soldered to a large enough breadboard so 220 ohm resisters could be soldered to all individual LED segment leads. The common cathode lead and the 7 LED leads were connected to a 2.54 mm male pin head connector for ease in wiring to the Arduino board.

C. Different color 3 vdc LED lights will be placed on the scoreboard to light up to the corresponding scoring hole that the putted golf ball just went through. I also used LED lights to indicate when a new game is started and when the 2-player button has been pressed. The colors are:

White = Ace

Blue = Birdie

Yellow = Par

Red = Bogey

Green = Reset/New Game

White (at bottom) = 1 vs. 2 Player

D. An Arduino Atmega2560 board was used to control the various components. I needed more input/output pins then a standard Arduino board.

E. A soldered breadboard distribution block was used for the I2C lines running to all the displays (4 digit, 7-segment LED and LCD monitor).

F. A power distribution block was purchased from Amazon. This was used to distribute all the 5V and common ground lines to each component. See below:

https://www.amazon.com/gp/product/B081XTSDGV/ref=p...

G. The last component needed was a 9-volt battery with a power cable.

H. Miscellaneous wire connectors need to connect the various components together

Arduino Bench Set-Up

Bench setup 1.jpg
Bench setup 3 Two player.jpg
Bench setup 4 LCD to check variables.jpg
Executive Golf Pin Assignments.jpg

The bench set-up is shown in the corresponding pictures. Pull-up buttons were used on the bench to mimic the break-beam IR sensors. I use a 4-line LCD monitor on my test bench to track variables and make sure the code controlling the scoreboard is working correctly. I like using this in place of the serial monitor.

The 7-segment LED displays are shown on the bench, both Player 1 and Player 2 score displays were shown to work correctly. After some editing of the Arduino code, I was able to get the single digit “hole” display to work correctly. The simulated 2-player, new game and double-bogey momentary push buttons and last golf ball scored LED lights were placed on the breadboard. They were all tested and shown to work correctly.

The Arduino pin assignment chart is also shown.

Arduino Code

The Arduino code to control the flow of the game and add up the scores correctly is attached.

The first part of the code includes some of the required Libraries you need. It also defines the Arduino pins for the IR sensors and the game control buttons, declares all the variables and defines two user defined functions. One function, sevenSegWrite(digit), controls the number displayed in the oversized, single-digit, 7-segment display (“Hole” you are playing) and the other function, controlscoreled(int), controls which LED is displayed (turned on) in the scoreboard.

In the setup() function I defined all the OUTPUT and INPUT pins. Note, the internal PULLUP resistor is used which uses an internal 20K ohm resistor pulled to 5 volts. This causes the input to read HIGH when the switch is open and LOW when it is closed. No accessory resistor is needed. I also initiated all variables and 7-segment digit displays and turned the “new game” green LED light on.

The loop() function starts by constantly reading all the INPUT pins. Then a specific “if” statement is executed depending on which input pin reads LOW (the button has been pushed or the IR sensor beam has been broken). The last “if” statement defines the end of the game. Once 9 “holes” have been played, the loop() function stops and the game is over.

Mounting the Components

Scoreboard Case 4 with mounting board for electronics 3.jpg
Scoreboard Case 4 with mounting board for electronics 5.jpg
Scoreboard Case scoreboard graphic from inside.jpg
I2C Bus branching 1.jpg
I2C Bus branching 3.jpg
Solder board for LEDS 1.jpg
Solder board for LEDS 2.jpg
IR Sensor Connector 1.jpg
IR Sensor Connector 2.jpg
Scoreboard Case 4 with mounting board for electronics 6.jpg
Start wiring components 1.jpg
Start wiring components 4.jpg
Start wiring components 2.jpg
Start wiring components 3.jpg
Scoreboard Case 4 with mounting board for electronics 8.jpg

First, drill holes and cut-outs had to be placed in the mounting board corresponding to the location each component occupies on the scoreboard graphic. Holes were drilled 5 mm in diameter to correspond to the LEDs. Rectangular holes were cut with a jigsaw to correspond to the dimensions of the various 7-segment displays.

Each LED light was soldered to a small breadboard with a resister connected to the positive terminal. Standard 2.54 mm male pin head connectors were used for the positive and negative terminals. The breadboard made it easier to secure the LED to the thin plywood mounting board. Each LED light assembly was mounted in their correct location on the mounting board. Small M1.7 diameter Phillip head steel screws were used to secure them.

Next, each 7-segment display had to be secured to the mounting board. Mounting holes at the 4 corners of the display PCBs were used with the same small mounting screws.

The Arduino mega board, power distribution block and I2C distribution block were secured to the mounting board base with small wood screws and spacers. Two other small breadboard were secured to the base on the right hand side at a 90 degree angle. These are the input pins for the IR sensors that have to be connected from the target assembly and the arcade buttons from the game control box that will be positioned by the player(s) putting.

A 9-volt battery and its harness were secured to the inside of the mounting board. The positive side of the cable will be spliced in with the on/off button switch on the wood scoreboard case.

Finally, all the components were connected, following the wiring scheme perfected on the bench setup.

Putting It All Together

Dowels seven eights.jpg
Drill Press use for hole 2.jpg
Scoreboard stands 3.jpg
Scoreboard stands 1.jpg
Electronic scoring button box.jpg
Scoreboard stands 5.jpg
Scoreboard stands 10.jpg
Electronic scoring final 7.jpg
Scoreboard stands 11.jpg
Connecting Cable 1.jpg
Cable connections on Scoreboard 1.jpg

The last step was to attach the scoreboard to the existing Executive Par 3 Golf Game in such a way that it did not interfere with the playing of the game. Also, any scoreboard attachment system would be removable so it could be packed and not impede the portability of the game. Similarly, I needed to make a stand for the button box so it was not resting on the ground and stationed nearer to were the players were putting.

Please look at the attached photos. 7/8” diameter dowels were used to raise the scoreboard case and the button case to the correct level. Three dowels were cut to 24” length. A plywood base with a 7/8” hole drilled in the middle was fabricated to accept one of the dowels. A corresponding pine piece of wood was attached to the back of the plastic button case. It also had a 7/8” hole drilled in the bottom to accept the other end of the dowel. Now the button case stand was complete. No glue is used. The stand is sturdy enough to be used while playing the game, but can be broken down easily for transport.

The scoreboard was attached to the target board assembly using the same concept. One surface of a 15” long piece of pine board was cut to a 60 degree angle to correspond to the 30 degree angle of the target assembly when it is set up to play. This places the top of this board horizontal. Two 7/8” holes were drilled 11” apart to accept the 24” long dowels and then the piece was screwed to the back of the target assembly. Next, a scrap piece of ¾” think pine was screwed to the bottom of the scoreboard case with matching 7/8” diameter holes drilled 11” apart. The two dowels were placed through the out-of-bounds netting and pushed in place on both the target board assembly and the bottom of the scoreboard case.

A 4-wire cable with the corresponding male connectors was run from the back of the scoreboard to the button case. A second 6-wire cable with the corresponding female and male connectors was run form the back of the target assembly (IR sensors) to the corresponding location on the back of the scoreboard. Now the electronic set-up was complete for automatic scoring while playing either a one player or two player version of the Executive Par 3 Golf Game.

Postscript

Making holes smaller 3.jpg
Making holes smaller 1.jpg
Electronic scoring final 2.jpg
Electronic scoring final 6.jpg

As I tested the game out, I noticed a golf ball dropping through a scoring hole was not always being counted. I wondered if the IR sensors were working correctly or if I would have to install more sensors. Then it occurred to me that at the extreme right and left side of the 3 ½” diameter hole the golf ball wasn’t being “seen” by the IR sensors placed right in the middle of the scoring hole (the IR beam wasn’t being broken). I found the diameter of a regulation golf ball is 1.68 inches. In mathematical terms, half of a 3 ½” diameter hole would be 1.75 inches. So I guess it is possible where the golf ball falls through the hole from the extreme left and right side and doesn’t break the IR beam.

In retrospect, I should have cut the scoring holes to a 3” diameter. But for this game, the simplest way to fix this was to flip the target board over and install some surplus vinyl floor edging on the left and right hand side of each hole. I placed the flexible vinyl so it overlapped the hole by ½” or so. When you flip the target board back over you will see that the material is below the edge of the hole and does not interfere with the golf ball freely falling through the hole.

This fixed the problem and the game has been working perfectly. In playing the game these last few weeks, I have not noticed any instance when the golf balls were not counted correctly in the player’s score.