We got a mini-golf for the office, which meant we had to find a way to keep track of how many times we actually scored.
Hardware
Sensors
There are several ways a system can detect the presence of an object (a rolling ball, a box on a conveyor belt, assembly line counting, inventory management, intruder detection...).
- Break-beam sensors have two ends, an emitter and a transmitter. The emitter sends out a beam of invisible infrared light and the receiver tells the device (in our case a TPS using Tibbit #00_1) if the light can be received or not. One drawback with IR sensors is that they can be affected by sunlight, but since we will only use the mini-golf indoors, that's not a problem. Other IR-based sensors can also detect proximity, but that's not required for our application.
- Sonar sensors could also be used (check here and here) but the break beam sensor is cheaper, faster, and smaller, making it more suitable for this application. Sonar sensors give the distance between the object and the sensor, which is also not required by this application.
- Ambient light sensors output a signal proportional to the intensity of received light. In theory, we could use one by placing it at floor level, pointing up, on the expected path of the ball, but the install process is too hands on, and the sensor readings could be very easily impacted by debris collected by the sensor.
- Pressure pads also a very valid alternative, although that would require more testing and callibration, as well as more physical modifications to the mini-golf track.
For this project, we decided to go for the break-beam sensor, as its fast, cheap, and easy to mount.
We use a Tibbit #00-1 for this project, but a much better alternative is either Tibbit #04-X (optically isolated inputs) or Tibbit #54 (four optically isolated dry contact inputs), for their noise and voltage protection.
Power
The break-beam sensor doesn't use much power at all, so a Tibbit #10 is enough for our application. We also use a Tibbit #00-3 to deliver power to both ends of the break-beam sensor, which makes the wiring a little more convenient for the 3D-printed TPS mount.
Mounting
Our mini-golf system looks a lot like the one in the image below. It has two "entry holes" and one "exit hole". The sensors are mounted inside of the wooden housing, right at the exit hole (check image for reference).

Wiring
The #00-1's 4th line is used to get input from the receiver's end of the sensor (the white wire). The fourth line of the #00_1 has four different modes (Input, Output, Keyboard Input, and Interrupt). Interrupt mode is faster than keyboard mode, but keyboard mode is more than enough to detect very fast moving balls. Additionally, keyboard mode is debounced, which means we don't have to handle inputs on our own.
We use a 9 terminal block to power the TPS (as opposed to the more 'conventional' Power Input Tibbit) to prevent the ball from accidentally hitting the ball. The Tibbit system is incredibly flexible, remember that when building your own systems!
Check out the following diagram to wire the sensor to the TPS.

Now that the hardware layout is done, we must configure line 4 of Tibbit #00-1 to use it as a button input. Click on the hardware tab of the editor, and on Tibbit #00-1

Check this tutorial for a more in-depth explanation of the different input modes.
Features
In features, there's not too much we need to worry about, we just need to enable the LCD, create a screen and add images for each digit 0-9.
Blocks
With all our hardware set up and ready to go, we can now start defining the logic of our system.
Main:
- score keeps track of how many balls have gone in one of the holes, and goes back to zero when the score is over 99 (although I really doubt we can get there)
- The On Button Pressed Event: T00_1_S1_L4_kp represents the keyboard input (4th line of Tibbit #00-1). To the TPS, the ball interrupting the IR beam is just a button press, and it increases the value of score every time it's "pressed".
7 Segment Display
The render_display command is triggered everytime the score changes, and it updates the images shown in the screen according to the digits in the tens and ones positions of score.
Manual Score Tracking
These controls are there in case we ever need to manually update the score.
Your smart mini-golf is now ready to roll!