Soccer Robot

Description:

Can you imagine that a robot can play soccer? This idea has became realistic. As we know, the RoboCup championship is generally held each year. In this part, we will create a soccer robot to play soccer.

How to install the soccer robot

Step 1 Remove two photoresistors

3_1


Required Parts 3_3


3_4


3_5


Step 2 Required Parts 5


5_1


5_2


Step 3 Required Parts 6


6_1


6_2


Step 4 Required Parts 7


7_1


7_2


Step 5 Required Parts 7_3


7_4


7_5


Step 6 Required Parts 7_6


Note the installation direction of the part marked by the red circle 7_7


7_8


Step 7 Required Parts 7_9


7_10


7_11


Step 8 Required Parts 8


Adjust the angle of the claw. Then make it close and face front 8_1


8_2


Step 9 Required Parts 8_3


Set the angle of the servo to 180 degree

Wire Up Servo

PCB Board

Brown

G

Red

5V

Orange

S2(GPIO23)

Upload the code of the servo to the main board of the Beetlebot car, as shown below

    #include <Servo.h>
    Servo lgservo;  // create servo object to control a servo

    void setup() {
    lgservo.attach(3);  // attaches the servo on pin 3 to the servo object
    }

    void loop() {
    lgservo.write(180); // tell servo to go to position
    }

Keep the claw close and face front before installing the gear

8_4


8_5


Step 10

Required Parts

3_6


3_7


3_8


Step 11

Required Parts

3_9


3_10


3_11


3_12


Wiring Diagram

Wire up the LEGO servo

IMG_256

Install a soccer goal

Step 1
Required Parts

2


2_1


2_2


Step 2

Required Parts 2_3


2_4


2_5


Step 3 Required Parts 2_6


2_7


2_8


Then the soccer goal is installed well.

Test Code:

#include <Servo.h>
Servo lgservo;
#define ML 15
#define ML_PWM 17
#define MR 14
#define MR_PWM 16
#define servo2 3

char val;
char wifiData;

void setup() {
Serial1.begin(9600);
pinMode(ML, OUTPUT);
pinMode(ML_PWM, OUTPUT);
pinMode(MR, OUTPUT);
pinMode(MR_PWM, OUTPUT);

lgservo.attach(3);
lgservo.write(180);
delay(1000);
lgservo.write(145);
}

void loop() {
if(Serial1.available() > 0)
{
    val = Serial1.read();
    Serial.print(val);
}
switch(val)
{
    case 'F': car_forward(); break;
    case 'B': car_back(); break;
    case 'L': car_left(); break;
    case 'R': car_right(); break;
    case 'S': car_stop(); break;
    case 'p': lgservo.write(180); break;
    case 'x': lgservo.write(145); break;
}
}


void car_forward()
{
digitalWrite(ML,LOW);
analogWrite(ML_PWM,127);
digitalWrite(MR,LOW);
analogWrite(MR_PWM,127);
}

void car_back()
{
digitalWrite(ML,HIGH);
analogWrite(ML_PWM,127);
digitalWrite(MR,HIGH);
analogWrite(MR_PWM,127);
}

void car_left()
{
digitalWrite(ML,HIGH);
analogWrite(ML_PWM,150);
digitalWrite(MR,LOW);
analogWrite(MR_PWM,105);
}

void car_right()
{
digitalWrite(ML,LOW);
analogWrite(ML_PWM,105);
digitalWrite(MR,HIGH);
analogWrite(MR_PWM,150);
}

void car_stop()
{
digitalWrite(ML,LOW);
analogWrite(ML_PWM,0);
digitalWrite(MR,LOW);
analogWrite(MR_PWM,0);
}

Build up the soccer goal with building blocks and place it at fixed location, connect the robot car through Wifi.

Put a small soccer in the middle of the claw of the robot car, press and hold down the button to enable the claw to hold the soccer, then press buttons to adjust the car’s movement direction so as to put the soccer close to the soccer goal. At last, release the button to allow the soccer to drop on the floor and roll to the soccer goal. If not, repeat the above step to shoot the goal.

If your friend owns this kind of soccer robot, you guys can hold a soccer match. It sounds amazing, right?.