ItR Mini Project 1: Painting Robot

Brief pics

Building Procedure

At the very beginning, all the materials we got is the Cherokey 4WD kit. Our initial idea is to build the robot following the Cherokey Instruction Manual provided by the manufacturer.

After finishing the installation of the motors and the Arduino board, we installed the server onto the robot.

Then we wanted to make the robot have the ability to detect the environment using its supersonic sensor. However, we can’t install the necessary library mentioned in the manual to control the supersonic sensor. Although we’ve already able to control the server. 

We ask our instructor Rudi for help. He gave us another infrared sensor which is much easier to use and control. So we removed the server, supersonic sensor, and the top board. After installing the infrared sensor, the prototype of our robot has been made.

After finishing the basic assembling of the robot, we started working with the code. We copied the test code from the manufacturer’s website and the robot worked well. After that, we manage to code the action on our own. At this time, we found that the control function has some problems. The “advance” function written by the manufacturer led our robot to turn left. Also, the “back” function led our robot to turn right. After checking the correctness of our cables and wires, we still have no idea about this. So we change the function on our own (by changing the “LOW” & “HIGH” index in the code to let turn left become advance, let advance become turn left… etc) and it worked finally.

Afterward, we write a code for obstacle avoidance. It can utilize the sensor to detect the obstacles in front of it. When there are obstacles, it will move back and forth at the former position.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As for the pattern we intended to draw, at first we want to draw a feather or leaf. We failed many times due to the unstable friction on the ground and canvas. In this case, we decided to draw the letter B as the symbolization of BOT. We asked Rudi for some paper to simulate the friction on the canvas and tried many times.

The code is as follows:

int speedPin_M1 = 5;     //M1 Speed Control
int speedPin_M2 = 6;     //M2 Speed Control
int directionPin_M1 = 4;     //M1 Direction Control
int directionPin_M2 = 7;     //M1 Direction Control
int sensor = 2;         //Sensor Control
void setup(){
  pinMode(2, INPUT);
  int i;
  for (i = 4; i <= 7; i++)
    pinMode(i, OUTPUT);
}
void loop(){
  int sensorState = digitalRead(sensor);
  if (sensorState == 1){
    carAdvance(250,250);
    delay(3000);
    carTurnRight(250,100);
    delay(7500);
    carTurnRight(250,250);
    delay(2500);
    carAdvance(250,0);
    delay(8000);
    carTurnRight(250,250);
    delay(1300);
    carStop();
    delay(1000000);
    // for (int j = 0; j <= 100; j ++){
    //   carBack(250,250);
    //   delay(100);
    //  }
    }
//   }else{
//     for (int j = 0; j <= 10; j ++){
//       carBack(250,250);
//     }
//   }
}
void carStop(){                 //  Motor Stop
  digitalWrite(speedPin_M2,0);
  digitalWrite(directionPin_M1,LOW);
  digitalWrite(speedPin_M1,0);
  digitalWrite(directionPin_M2,LOW);
}
void carTurnLeft(int leftSpeed,int rightSpeed){         //Move backward
  analogWrite (speedPin_M2,leftSpeed);              //PWM Speed Control
  digitalWrite(directionPin_M1,HIGH);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,HIGH);
}
void carTurnRight(int leftSpeed,int rightSpeed){       //Move forward
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,LOW);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,LOW);
}
void carBack(int leftSpeed,int rightSpeed){      //Turn Left
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,LOW);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,HIGH);
}
void carAdvance(int leftSpeed,int rightSpeed){      //Turn Right
  analogWrite (speedPin_M2,leftSpeed);
  digitalWrite(directionPin_M1,HIGH);
  analogWrite (speedPin_M1,rightSpeed);
  digitalWrite(directionPin_M2,LOW);
}
 
The function is the modified one. We control our robot to turn right by giving different values to the left and right motors. When the left motor has higher power than the right side, it can turn right successfully. We also use delay(parameters) to let the robot know how long the going advance procedure and the turning procedure are.
 
 
Finally, when all the pieces of stuff are ready, we did some decoration for the robot. We use cardboard to make the cover of the robot and use hot glue to stick it to the nylon post. We also use hot glue and tape to stick the brush on the robot and use cardboard to support it. We also made eyes and nose to let the robot looks smarter (actually cuter).
 
 
Then it’s the final day. We paint our brushes with blue and white paint and start the robot. It drew a perfect letter B (although not very obvious)!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
After this project, we still have many issues that need to be improved. Like we need to extract a higher force on the brush to make the paint clearer on the canvas. Also, we should optimize our code to enable the obstacle avoidance function.
 
Hope we can do better next time!
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *