Introduction: Ping Pong Faulty Serve Detector
Those of you who like to play Ping Pong know that a serve in which ball touches a net before hitting the opponent's side of the table is a faulty serve (or a "let" in the official speak). You also know that sometimes the ball touches the net so lightly that it is hard to say whether it did or did not.
The idea is to build a faulty serve alarm by attaching a vibration sensor to the side of the net, and creating a small device that beeps every time a ball (or something else) hits the net and makes it vibrate.
To make this practical and less annoying the device should:
- Beep and flash an LED when net is disturbed
- It should only beep once and pause for a reasonable time (at least until the net is not vibrating anymore)
- Beep only after a certain level of vibration is detected (thus avoiding false beeping on small vibrations caused by the ball bouncing off the table)
I found this to be a perfect candidate for an Attiny85 based device.
Step 1: Parts
You will need the following parts for this project:
Adjustable Sensitivity Vibration Sensor Module for Arduino (1) - on amazon.com
- Attiny85 based development board (1) - on amazon.com
KEYES Arduino Compatible Active Speaker Buzzer Module (1) - on fasttech.com
- White (or any color you like) LED (1)
- Resistor 220 Ohm (1)
- Variable resistor 10 KOhm (1)
- Wires, veraboard, female headers, soldering equipment and supplies
- Binder clips like these
Step 2: Schematics
Attached picture represents the device schematics. The development board conveniently has the form factor of the USB plug, which eliminates the need for a cable.
Step 3: Working With RobotDyn ATtiny85 Development Board
ATtiny85 development board requires a bit of work to integrate into Arduino IDE.
Once done, it is a simple device to work with and I had no issues uploading sketches to it.
Please NOTE: This simple device does not have reset buttons or a full-blown USB controller, so the process of sketch upload is different from other Arduinos (e.g. Uno or Nano) or ESP8266 devices. Once the sketch has been compiled and is ready to be uploaded inside IDE, the device should be plugged in. The upload is lightning fast (thanks to small memory size!).
A great tutorial on how to install drivers and set up Arduino IDE to work with ATTiny85 board is here: on digistump.com
Product page: on robotdyn.com
Step 4: Sketches and Files
That's it, folks.
Upload the attached sketch into ATtiny85, plug it into a rechargeable USB battery like the one pictured above, and enjoy sensor-assisted ping pong serves.
Sketches and fitzing files are located on Github.com here.
AvgFilter library is located here.
TaskScheduler labrary is located here.
TM1650 library is located here.
EnableInterrupt library is located here.
Step 5: Fine-tuning
If you like to fine-tune things, you could use a contraption pictured above for the purpose.
It is based on Arduino Uno and a TM1650 7 segment display.
TM1650 is I2C based device, so connecting it to Uno is easy (VCC, GND, SDA and SDL to appropriate pins).
Vibration sensor and buzzer are connected to the same numbered pins as with ATTiny85 (1 and 4 respectively).
Current algorythm takes continuous measurement of the Vibration Sensor every 10 ms over 50 samples.
Each time the pin is HIGH, a value of 100 is added to the averaged set.
Each time the pin is LOW, a value of 0 is added.
If the average is above certain threshold, the buzzer is activated.
Using the device, you could play with the parameters and find the one that works best for your table and net.
- STEP 10 // sensor reading interval, ms
- MIN_TO_BEEP_AV 30 // min threshold to beep
- MIN_TO_ARM_AV 0 // max threshold to keep silent
- DATA_SAMPLES 50 // number of data samples for average filter
- NO_BEEP_TOUT 3 // seconds - no repeat beeps for this period of time
- SLEEP_TOUT 60 // seconds - put attiny85 into deep sleep after no vibration for this time
Fine tune away!