Introduction: Robot Project

In this project I was tasked to make a robot that could acquire a ball and launch it into a goal. In this Instructable I will be showing how to make the robot that will be able to do this.

Step 1: The Goal and Restrictions

The goal for this robot was to make it able to acquire a ball and launch it into a goal. The acquiring of the ball will be manually operated while the process for launching he ball will be autonomous.

The restrictions for making this robot is that it has to fit into a 1 by 1 foot square.

Step 2: Materials Needed

Here are the list of materials that will be needed to build this robot.

50 Male to male wires
50 male to female wires

50 female to female wires

1 Arduino Uno/Arduino Mega 2560

4 Wheels 2 Ball Casters

4 Motors

4 Motor Mounts

Assorted Aluminium Sheets *ALL MEASUREMENTS ARE IN INCHES AND ARE ⅛” THICK* (4) 2 x 10 (4) 1.189 x 1.598 (4) 1.345 x .663 (2) 1.75 x 1.598 (2) 7 base, 3.861 high, and 10 hypotenuse (2) 10 x 10 (1) 3.861 x 10 (1) 7 x 10

1 Battery

1 Motor Driver

1 Remote Controller with Receiver

38 Nuts

38 Bolts

Step 3: Schematics

Here are the schematics for this robot. Using this we will be able to clearly see what we will need to build and what it should look like.

Step 4: Drive Train

Our drive train will be a direct drive. Since we will have 2 wheel being used for driving we will use ball casters to provide the ability to be stable while still being able to turn. This will look similar to a roomba's drive train.

Step 5: Ball Retrieval Method

To retrieve the ball we will be using compliant wheels which will turn to acquire the ball and launch the ball.

Step 6: Wiring

This is the wiring for the components of the robot.

Step 7: Programming

In the programming side, the robot will run on simple RC commands, and when it comes time for the robot to switch over to autonomous, it has been programmed to go to the goal in 3 simple steps. First, it will find the colored tape on the floor that was pre-applied(and lined up to the goalpost) by retracing its steps. Next, it will go in small movements to catch the difference in color values between the floor and a line of electrical tape, once it reaches the end of the line, where the sensor picks up the intersection between lines of tape, it will stop and reverse the direction of the compliant wheels to eject the ball into the goal.

Step 8: Code for Color Sensor

#include "DEV_Config.h"

#include "TCS34725.h"

RGB rgb,RGB888;

UWORD RGB565=0;

void setup()

{ Config_Init();

if(TCS34725_Init() != 0){

Serial.print("TCS34725 initialization error!!\r\n");

return 0;

}

Serial.print("TCS34725 initialization success!!\r\n");

}

void loop()

{

//gets the values of the colors.

rgb=TCS34725_Get_RGBData();

RGB888=TCS34725_GetRGB888(rgb);

RGB565=TCS34725_GetRGB565(rgb);

Serial.print("RGB888 :R=");

Serial.print(RGB888.R);

Serial.print(" G=");

Serial.print(RGB888.G);

Serial.print(" B=");

Serial.print(RGB888.B);

Serial.print("\r\n");

Serial.print("RGB565= 0x");

Serial.println((RGB565), HEX);

if(TCS34725_GetLux_Interrupt(0xff00, 0x00ff) == 1){

Serial.print("Lux_Interrupt = 1\r\n");

}

else

{

Serial.print("Lux_Interrupt = 0\r\n");

}

Serial.print("\r\n");

DEV_Delay_ms(1000);

}

Step 9: Code for Moving With Controller

int ch1;

int ch2;

int ch3;

int ch4;

const int m1f = 9;

const int m1b = 11;

const int m2b = 2;

const int m2f = 5;

const int m1s = 3;

const int m2s = 4;

void setup() {

// put your setup code here, to run once:

pinMode(22, INPUT);

pinMode(23, INPUT);

pinMode(24, INPUT);

pinMode(25, INPUT);

pinMode(m1f, OUTPUT);

pinMode(m1b, OUTPUT);

pinMode(m2b, OUTPUT);

pinMode(m2f, OUTPUT);

pinMode(m1s, OUTPUT);

pinMode(m2s, OUTPUT);

Serial.begin(9600);

}

void loop()

{

// put your main code here, to run repeatedly:

//reads values from the controller

ch1 = pulseIn(22, HIGH);

ch2 = pulseIn(24, HIGH);

ch3 = pulseIn(23, HIGH);

ch4 = pulseIn(25, HIGH);

Serial.print("ch1: ");Serial.print(ch1); Serial.print("ch2: ");Serial.print(ch2);Serial.print("ch3: ");Serial.print(ch3);Serial.print("ch4: ");Serial.println(ch4);

//determines when to move the robot based on values from the controller.

if(ch3>1750)

{

motorforward(m2f, m2b, m2s, 200);

}

else

{

if(ch3<1250)

{

motorbackward(m2f, m2b, m2s, 200);

}

else

{

motorstop(m2f, m2b, m2s);

}

}

if(ch2>1750)

{

motorforward(m1f, m1b, m1s, 200);

}

else

{

if(ch2<1250)

{

motorbackward(m1f, m1b, m1s, 200);

}

else

{

motorstop(m1f, m1b, m1s);

}

}

}

void motorforward(int forward, int backward, int motorspeed, int spd)

{

digitalWrite(forward, HIGH);

digitalWrite(backward, LOW);

analogWrite(motorspeed, spd);

}

void motorbackward(int forward, int backward, int motorspeed, int spd)

{

digitalWrite(forward, LOW);

digitalWrite(backward, HIGH);

analogWrite(motorspeed, spd);

}

void motorstop(int forward, int backward, int motorspeed)

{

digitalWrite(forward, LOW);

digitalWrite(backward, LOW);

analogWrite(motorspeed, 0);

}

Step 10: Code for Using the Motor Encoder

int encoder2;

int encoder;

int chA; int chB;

const int m1f = 2;

const int m1b = 7;

const int m1s = 9;

const int m2b = 11;

const int m2f = 3;

const int m2s = 5;

void setup()

{

pinMode(21, INPUT);

pinMode(24, INPUT);

pinMode(m1f, OUTPUT);

pinMode(m1b, OUTPUT);

pinMode(m1s, OUTPUT);

pinMode(m2f, OUTPUT);

pinMode(m2b, OUTPUT);

pinMode(m2s, OUTPUT);

//Used to count how many times a pin goes from HIGH to LOW.

attachInterrupt(3, count2, FALLING);

//attachInterrupt(2, count, FALLING);

//encoder = 0; encoder2 = 0; Serial.begin(9600);

}

void loop()

{

//Reading values from the motor's encoder.

chA = digitalRead(21);

chB = digitalRead(24);

//Serial.print("chA: "); Serial.print(chA);

//Serial.print("chB: "); Serial.println(chB);

//Serial.println(encoder);

Serial.println(encoder2);

/*

if (encoder <= 250)

{

motorforward(m1f, m1b, m1s, 75);

}

else

{

motorstop(m1f, m1b, m1s);

}

*/

//Determines when to stop the motor.

if (encoder2 <= 250)

{

motorforward(m2f, m2b, m2s, 75);

}

else

{

motorstop(m2f, m2b, m2s);

}

}

void motorforward(int forward, int backward, int motorspeed, int spd)

{

digitalWrite(forward, HIGH);

digitalWrite(backward, LOW);

analogWrite(motorspeed, spd);

}

void motorbackward(int forward, int backward, int motorspeed, int spd)

{

digitalWrite(forward, LOW);

digitalWrite(backward, HIGH);

analogWrite(motorspeed, spd);

}

void motorstop(int forward, int backward, int motorspeed)

{ digitalWrite(forward, LOW);

digitalWrite(backward, LOW);

analogWrite(motorspeed, 0);

}

void count()

{

encoder ++;

}

void count2()

{

encoder2 ++;

}