Project tutorial
Arduino-Based Butler Robot

Arduino-Based Butler Robot © GPL3+

It's an Arduino-based robot which brings food from the kitchen to my room.

  • 1,688 views
  • 3 comments
  • 5 respects

Components and supplies

About this project

I wanted to create a robot that could bring snacks and all sorts of food items from kitchen to my room, so I took few parts (aluminum channel and sheet) and combined them together to make this easy but working "butler robot."

Watch the video!

Code

Untitled fileC/C++
int motorLpin1 = 2;
int motorLpin2 = 3; 
int motorRpin1 = 4;
int motorRpin2 = 5;
int rightMotorENA = 6;
int leftMotorENB = 9;



int motorSpeed = 255;
int turn=50;
void setup()
{
  Serial.begin(9600);
  Serial.flush();
  pinMode(motorLpin1,OUTPUT);
  pinMode(motorLpin2,OUTPUT);
  pinMode(motorRpin1,OUTPUT);
  pinMode(motorRpin2,OUTPUT);
  pinMode(rightMotorENA,OUTPUT);
  pinMode(leftMotorENB,OUTPUT);

}

void loop(){
  String input="";
  while(Serial.available()){
    input+=(char)Serial.read();
    delay(5);
  }
    
  if(input=="n"){
    MotorStop();
  }
  else if(input=="F"){
    MotorForward();
  }
  else if(input=="R"){
    MotorBackward();
  }
  else if(input=="TL"){
    MotorLeft();
  }
  else if(input=="TR"){
    MotorRight();
  }
  
  else if(input=="RR"){
    rightRight();
  }
  
  else if(input=="M"){
    StraightStraight();
  }

 
 
}

void MotorForward(void)
{
  digitalWrite(motorLpin1,HIGH);
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
}

void MotorBackward(void)
{
  
  digitalWrite(motorLpin1,LOW);
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,LOW);
  digitalWrite(motorRpin2,HIGH);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);  
}
void MotorLeft(void)
{
  digitalWrite(motorLpin1,HIGH);
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,LOW);
  digitalWrite(motorRpin2,HIGH);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
}
void MotorRight(void)
{
 
  digitalWrite(motorLpin1,LOW);
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255); 
}
void MotorStop(void)
{
  
  digitalWrite(motorLpin1,LOW);
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,LOW);
  digitalWrite(motorRpin2,LOW);
  digitalWrite(leftMotorENB,LOW);
  digitalWrite(rightMotorENA,LOW);
}




void rightRight(void){
  
  digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(600);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(600);
}

void StraightStraight (void){
  
  digitalWrite(motorLpin1,HIGH); //staright
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500); 

  digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

   digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500); 

  digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

    digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500); 

  digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

   digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500); 

  digitalWrite(motorLpin1,LOW);   //turn right 
  digitalWrite(motorLpin2,HIGH);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(100);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);

  digitalWrite(motorLpin1,HIGH); //straight
  digitalWrite(motorLpin2,LOW);
  digitalWrite(motorRpin1,HIGH);
  digitalWrite(motorRpin2,LOW);
  analogWrite(leftMotorENB,255);
  analogWrite(rightMotorENA,255);
  delay(4000);
  analogWrite(leftMotorENB,LOW);
  analogWrite(rightMotorENA,LOW);
  delay(500);  
}

Schematics

controlador-de-motores-doble-puente-h-l298_a4Z1PK3or6.jpg
Controlador de motores doble puente h l298 a4z1pk3or6

Comments

Similar projects you might like

MeArm Robot Arm - Your Robot - V1.0

Project tutorial by Benjamin Gray

  • 19,315 views
  • 3 comments
  • 35 respects

Jrobot - Android and Arduino-Based Global Control Robot Car

Project showcase by joechen

  • 5,662 views
  • 4 comments
  • 20 respects

Line following Robot

Project tutorial by Arnov Sharma

  • 232 views
  • 0 comments
  • 4 respects

Otto DIY+ Arduino Bluetooth Robot Easy to 3D Print

Project tutorial by Team Otto builders

  • 48,282 views
  • 117 comments
  • 162 respects

Two Mode Robot Controlling through Android and Windowsphone8

Project tutorial by Anas Siddiqui

  • 16,314 views
  • 9 comments
  • 48 respects

MyRobot - Made To Control A Whole Robot

by Tiago Alves

  • 4,896 views
  • 1 comment
  • 17 respects
Add projectSign up / Login