soccer robot complete tutorial with code

This post is the second part of the previous tutorial we have started about making Soccer robot for RoboCup.In the first part, we have discussed the mechanical parts.In this post, we will see about the Electronics part.
So here is the link for the previous part:


Electronic Parts

  1.  Battery
  2.  Power distribution circuit
  3.  H-bridge
  4.  Arduino
  5.  NRF-module
  6.  Boost Converter
  7.  Ball detector circuit
  8.  Solenoid


The battery is providing source to each component and it is selected as per requirement of
the current. We have selected the lipo battery for our robot because it’s a light weight and
provide us our required current. Our Battery consist of 5 lipo cells each cell having
3.7volts total of 18.5volts battery having 5000mAh current.
  • Output voltage 18.5V
  • Initial Current 5A Max
  • Discharge (c) 25
  • Max Charge Rate (C) 2
  • Weight (g) 640
  • Length(mm) 146
  • Height(mm) 51
  • Width(mm) 42

Power Distribution circuit

In the robot we needed 3 different voltages to operate our devices first our battery contains
18.5 volts which are needed to operate motors secondly we needed 12 volts to operate our
motor driver IC IR2104, dribbler motor and for booster circuit because the input of our booster is
12 volts. In last we needed 5 volts to operate our controller Arduino and for ball detector

For this purpose, we design two regulators for step down voltages by using LM7812 and
LM7805 the circuit diagram are as follow.
12-volt regulator circuit consists of
  1.  LM7812
  2.  diode
5volt regulator circuit consists of
  1. LM7805
  2. diode
  3. capacitor

Arduino Development Board

I am not going to discuss the basics of Arduino can read about Arduino in these following posts.

Wireless Communication using nRF24L01

The wireless communication is done between various nodes. Since we are at the node of between
receiving data from GUI, therefore wireless module is used. The controlling of the robot is being
done by using a joystick. The module which we used for wireless communication is nRF24L01.

I already discussed complete details about Nrf and Arduino interfacing.Read the detailed post of nrf24Lo1+. Arduino codes for Nrf are also available in that post.


A solenoid consists of a coil of insulated wire. We have to design solenoid to provide strong inner
the magnetic field in order to fulfill our purpose of the kicking mechanism. For this purpose Teflon
the material is used on which copper is wounded when current flows through the coil then strong
the magnetic field is produced within the core due to which kicking mechanism of the robot will
One more post is available for kicker mechanism and solenoid.You can get the design files from there.

specification of the solenoid:

  1. Wire gauge 30 AWG
  2. Input voltage 230 V
  3. Number of turns of Cu wire 1800
  4. Resistance/meter of Cu wire 0.339
  5. Diameter of Teflon 8mm

Ball Detector Circuit

To start the dribbler we have designed the ball detector circuit which is mounted on the sides of
dribbler by using IR sensor. When there is no object the receiver receives the signal from
the transmitter and when the ball comes to our robot the signal will be disconnected the receiver will
not generate the output signal and then this logic is inverted through using the NOT gate and it will
generate a signal to operate the motor driver for the dribbler. The circuit is shown in the figure.
See the Circuit Diagram:


For the kick, we have to energize our coil and to energize the coil we needed high voltages for
this purpose we have designed the boost converter which converts the 12 volts into 220 volts.

See the Detailed post about Booster 

Motor Driver

To control the direction and speed of motor we have to use motor drivers.
I have done this part using L298 is and also with L298 module.
See the related post on this part.


The first step was to control robot manually by using remote and wireless communication this step
was done by using Arduino and Nrf we first manually control the robot and check its parts are
properly working and seeing its direction by controlling motors.
Here is the Code for Arduino boards:


The Code is quite long so I'm not going to past it here.If you need the file then comment below.

Concluding Statement:

After these steps, we proceed to the Artificial intelligence, after controlling manually robot. First, we
serially communicate it with GUI through NRF module. One end of NRF is interfaced with
Arduino UNO R3 and on another end we used Arduino MEGA 2560.
in SSL vision the camera captures the image of the robots playing and ball by using color pattern
embed on them. This information is broadcasted through WIFI modem. This then is received by
our PCs and this information extracted from the file provided by management of the event
named as ‘protobuf.’ This information is further utilized to calculate and make the strategy for
our robots on the field and predict the movement of opponent and ball using Line equations and
orientation. This smart intelligence is used to make a strategy. This strategy is used to calculate the
directions and PWMs of all the motors mounted on each robot. Then transmitted to our robot
through NRF modules. For this AI server, we are using multi threading in C# to process for 2
robots at the same time.
I hope you understand the method and sequence of steps.Half of the things I have covered in separate posts so that's why I didn't discuss everything here.
In coming post, we will see how to setup the field for an autonomous robot.Installation of SSL software and testing with example code.
Follow for upcoming updates as still there is much more left about an autonomous we will cover up everything in coming posts.
I hope you enjoyed it.keep making robots.

Share To:

Post A Comment:

3 comments so far,Add yours

  1. I need this code of robo soccer

  2. I need this code of robo soccer

    1. Here is the download google drive link: