Month of Robots

Enter Your Project for a chance to win robot prizes for your robot builds and a $200 shopping cart!  The Birthday Special: Robot Prizes for Robot Projects!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll


This month’s theme Robot on Wheels had me excited, and though I have been kind off busy at work, I knew I had to post a project. I have been working on a 3D design to create a simple robotic platform which is easy to 3D print. This is the second version of the 3D printed parts with improvements, and I have called it the -  CupRobot, as I am using a cold coffee cup to protect the electronic components , but feel free to suggest a name if you come with something more interesting, or some enhancements you would like to see with the bot.


Here is a picture of the 3D printed parts, you can use PLA or ABS and you will not require any support material while 3D printing. STLs files for the 3D printed parts attached.

#1 base to hold the motors

#2 holder for the Arduino Uno

#3 back wheel

#4 holder for the AA battery holder

#5 in addition if you plan to add an ultrasonic sensor you will need to 3D print another holder, which king of gives the CupRobot its eyes ..



For putting the components together you will need 4-40 screws and nuts, which you can get at your local hardware store.


Here are the circuit connections using the Sparkfun motor driver(TB6612FNG) and Arduino Uno.

  • PWMA on the motor driver connected to pin# 5
  • AIN1 to pin# 1
  • AIN2 to pin# 2
  • PWMB to pin# 6
  • BIN1 to pin# 11
  • BIN2 to pin# 12

And for the ultrasonic sensor(HC-SR04) connected to

  • Trigger Pin  to Arduino pin #9
  • Echo Pin to Arduino pin #10



Here is video demo of the CupRobot in action..



Arduino code used to test the movement, as you see in the video above.

//Sample code for Project14-Robots with Wheels - CupRobot project - Basic version
//Motor Driver Pin Connections to Arduino Uno
int STBY = 4; //standby
//Motor A -left
int PWMA = 5; //PWM pin for Speed control
int AIN1 = 1; //Direction
int AIN2 = 2; //Direction
//Motor B - right
int PWMB = 6; //PWM pin for Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction
//Ultrasonic  sensor pins numbers
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distance;
//Change this value to adjust the senstivity of the HC-SR04
const int maxDistance = 15;

void setup() { 
  //Setting the trigPin as an Output
  pinMode(trigPin, OUTPUT); 
  //Setting  the echoPin as an Input
  pinMode(echoPin, INPUT);
  //Setup Motor pins
  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(STBY, OUTPUT);
  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
  //Starts the serial communication to help debugging

void loop() {
  // Clear the trigPin
  digitalWrite(trigPin, LOW);
  //Sets the trigPin to HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  //Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  //Calculating the distance
  distance= duration*0.034/2;
  //Prints the distance on the Serial Monitor- use this to modify the maxDistance above
  Serial.print("Distance: ");
  if(distance < maxDistance){ //obstacle detected in front, move back and then turn left
  }else{ //keep moving foward
  //uncomment this section, and comment the if-else section above to test the direction of the motor spining

//Driving the CupRobot functions
void turn(int speed,char side){
  digitalWrite(STBY, HIGH);//enable the standby pin
  if(side == 'L'){ //left turn
    digitalWrite(AIN1, HIGH);
    digitalWrite(AIN2, LOW);
    analogWrite(PWMA, speed);
    digitalWrite(BIN1, LOW); //Stop motor B
    digitalWrite(BIN2, LOW);
    analogWrite(PWMB, speed);
  }else{ //Right turn
    digitalWrite(AIN1, LOW);//Stop motor A
    digitalWrite(AIN2, LOW);
    analogWrite(PWMA, speed);
    digitalWrite(BIN1, HIGH);
    digitalWrite(BIN2, LOW);
    analogWrite(PWMB, speed);


void move(int speed,char moveDirection){
digitalWrite(STBY, HIGH);//enable the standby pin
if(moveDirection =='B'){
    digitalWrite(AIN1, LOW);
    digitalWrite(AIN2, HIGH);
    analogWrite(PWMA, speed);
    digitalWrite(BIN1, LOW);
    digitalWrite(BIN2, HIGH);
    analogWrite(PWMB, speed);

    digitalWrite(AIN1, HIGH);
    digitalWrite(AIN2, LOW);
    analogWrite(PWMA, speed);
    digitalWrite(BIN1, HIGH);
    digitalWrite(BIN2, LOW);
    analogWrite(PWMB, speed);

void stop(){
//disable standby
  digitalWrite(STBY, LOW);