Mechatronics Exercises

Workspace Navigation


Juutinen Taneli, Kivistö Teppo, Särkelä Ollimatti

Project description

The goal of this project is to make a beer pong robot, which can detect the location of a cup on the playing surface and shoot a ping pong ball to said cup. The cup detection is handled with ultrasonic sensor running on a Arduino Uno and the robots aim is controlled by two servo motors orienting horizontally and vertically. Correct position is calculated by simulating the flight trajectory with MATLAB. The ball is finally launched with a solenoid and an external power supply.


What has been done?

All parts have been ordered and have now arrived. We have done calculations on the aerodynamic effects on the trajectory of the ball. We have written code for sensing the location of cups. Preliminary CAD models are ready. We changed the sensing mechanism from computer vision to an ultrasonic sensor that does a sweep to sense what is in front of the launcher. This was done due to it being much cheaper and less complex.

What still needs to be done?

We need to 3D print the structure for the launcher and assemble it. Then we need to determine the shooting velocity of the launcher by doing some test shots. The code needs to be refined and there is much further development that can be done with it. We may need to procure diodes.

Problems and challenges:

Ordering parts took longer than expected. All the 3D printers were reserved at ADDlab. 

Final Documentation

The system works by sensing the nearest cuo to it and shooting a ball into it. It does this by sweeping an angle in front of the device by turning a servo motor and measuring the distance to the nearest object at every servo position from data gathered by an ultrasonic sensor. The system remembers the smallest measured distance and the servo position of the measurement. After the sweep, the device locks onto the nearest cup it found and calculates the shooting angle of the. Since the starting velocity of the ball is near constant and air resistance is negligible, the shooting angle is just a function of distance. After aiming the device at the target, the device waits for the reset button to be pressed. The reset button is a simple button attached to a breadboard, which when pressed allows the arduino loop to continue. The shooting of the ball is done by a solenoid driven by a variable power supply. The solenoid is activated by pressing a button that closes the circuit. The solenoid is in a different circuit to the rest of the system.

In addition to the automatic cup position detection and flight trajectory calculation, we included a manual positioning system with two potentiometers controlling the two servos.

BePo-Bot video.MP4

List of components

  • Arduino Uno microcontroller
  • Two SG90 micro servo motors
  • HC-SR04 ultrasonic distance sensor
  • Heschen HS-0530B 12V 5N solenoid for shooting the ball
  • Two salvaged 10kohm potentiometers for manual control
  • Breadboard button for resetting the system
  • Another, more durable button for launching the solenoid
  • External adjustable power supply unit
  • Breadboard and a bunch of wires

We had initially ordered a 12V 5A power supply for the solenoid, since the solenoid is rated for 12V 1A. This proved way too underpowered for our needs, so we ended up using a more beefy power supply which provided us with 30V 2A. The solenoid was wired in its own circuit with the power supply and launch button, as we feared we would end up blowing up our other components if we wired them all together. The Arduino powered everything else, and was itself powered via USB cable from a laptop.

The robot itself is fully 3D-printed, as is the manual control panel.

Electric circuit design if the system:

Arduino code

We had two different programs for the robot, one where the aiming was fully automatic and another where the user could manually adjust the aim using potentiometers. We did not have enough time to combine these two codes so that both features could work at the same time, although this is something that we could have done had we had more time.


Flight path calculation

We ended up with the following formula for the required angle for shooting the ball:


, where x is the distance, g is the gravitational constant and v0 is the initial velocity of the ball.

We also simulated the effects of air resistance and concluded it was not significant. All of this is explained in more detail in the file "Flight path calculation".

  • No labels
  File Modified
JPEG File BePo.jpg Apr 13, 2023 by Teppo Kivistö
PNG File bepobot_asm.PNG Mar 14, 2023 by Taneli Juutinen
JPEG File BePo-Bot_juliste.jpg May 08, 2023 by Ollimatti Särkelä
File BePoBot_pot_control.ino Apr 28, 2023 by Taneli Juutinen
Multimedia File BePo-Bot video.MP4 May 08, 2023 by Ollimatti Särkelä
File botti_koodi_toimiva_kommentoitu.ino Apr 28, 2023 by Taneli Juutinen
PNG File circuit.png May 03, 2023 by Taneli Juutinen
PDF File Flight path calculation.pdf Apr 23, 2023 by Ollimatti Särkelä
File pingis.m May 04, 2023 by Taneli Juutinen
File pingissim.slx May 04, 2023 by Taneli Juutinen
File pingissim2.slx May 04, 2023 by Taneli Juutinen