Final Project – Butler Bot

For my final project, I would like to build an Arduino Robot, “Butler Bot”. This idea came to me when I was doing my 2nd project of the semester, “Find my iPhone”. The function of this robot is to move from one place to another, with the capability of avoiding any obstructions that might be in its way. A will serve as a sort of home for the wiring, as to make it look as effortless as possible.

The functionalities include a ultrasonic sensor, which will allow the robot to navigate freely without anything blocking its movement or interfering with its set directions. A remote will be used to navigate the robot, with the various buttons being assigned to different directions. 1= ON/OFF, 2=Right, 3=Left, 4=Backward, 5=Forward, 6=spin, etc.

The robot is sturdy enough to carry items, which is why I affectionately named it “Butler Bot”. The wooden exterior housing allows for items to be placed on top of the robot, so if you’re in the living room and need a drink, you can send the robot into the kitchen and whom ever is in there could send a drink your way with ease and convenience. Of course that’s just an example from my lazy mind, there are many other creative uses for the robot, it all just depends on how imaginative the user is.

MATERIALS:

-wood
-arduino
-ultrasonic sensor
-remote control
-IR receiver
-3Mohm resistor
-lots of jumper cable
-breadboard
-a pair of wheels
-drill
-bolts and nails
-servo motors
-9volt battery
-tape
-LED Light

  

CODE (Final):

#include <IRremote.h>
#include <Stepper.h>
const int irReceiverPin = 7;
//const int ledPin = 13;
const int stepsPerRevolution = 512;  // change this to fit the number of steps per revolution for your motor
int ctr = 0; //counter for button presses
const int trigPin = 13;
const int echoPin = 8;
int max_Distance = 4;
float  inches;
int x= 0;
//float cm;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 2, 4, 3, 5);
Stepper myStepper2(stepsPerRevolution, 9, 11, 10, 12);
IRrecv irrecv(irReceiverPin);
decode_results results;
void setup()
{
  myStepper.setSpeed(80);
  myStepper2.setSpeed(80);
  // pinMode(ledPin, OUTPUT);
  irrecv.enableIRIn();
  Serial.begin(9600);
}
void loop() {
  if (irrecv.decode(&results))  {
    Serial.print(“irCode: “);
    Serial.print(results.value, HEX);
    Serial.print(“,  bits: “);
    Serial.println(results.bits);
    delay(200);
    irrecv.resume();
 
  }
  if (results.value == 0xE318261B) { // ON / Off
    ctr++;//if button is pressed, counter goes up by one
   // Serial.print(“counter: “);
  //  Serial.println(ctr);
    StopGo();
  }
 
  if( inches > max_Distance) {
    
  if (results.value == 0xFF5AA5) { //
    Backward();
    // checkDistance();
  }
  if (results.value == 0xFF10EF) { //
    Left();
    // checkDistance();
  }
  if (results.value == 0xFF38C7) { //
    Forward();
    // checkDistance();
  }
  if (results.value == 0xFF7A85) { //
    Right();
    // checkDistance();
  }
}
  
x = x+1;
Serial.println(x);
if (x> 10) {
    checkDistance();
    delay(100);
  x = 0;
}
}
void drive () {
}
void StopGo() {
  if (ctr % 2 != 0) { // On / OFF
    //   digitalWrite(ledPin, HIGH);
    Serial.println(“ON”);
  }
  if (ctr % 2 == 0) {
    Serial.println(“OFF”);
    //  digitalWrite(ledPin, LOW);
    //delay(200);
  }
}
void Forward () {
  myStepper.step(1);
  myStepper2.step(-1);
  Serial.println(“Forward”);
}
void Backward () {
  myStepper.step(-1); //driver seat
  myStepper2.step(1);
  Serial.println(“Backward”);
}
void Right () {
  myStepper.step(-1);
  myStepper2.step(-1);
  Serial.println(“Right”);
}
void Left () {
  myStepper.step(1);
  myStepper2.step(1);
  Serial.println(“Left”);
}
void checkDistance() {
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;
  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);
  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  Serial.print(inches);
  Serial.print(“in, “);
  Serial.print(cm);
  Serial.print(“cm”);
  Serial.println();
  delay(100);
  //else {
//    myStepper.setSpeed(100);
//    myStepper2.setSpeed(100);
//  }
}
long microseconds To Inches(long microseconds)
{
  // According to Parallax’s datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance traveled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}
long microseconds To Centimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance traveled.
  return microseconds / 29 / 2;
}
// /*
// #1 = 9716BE3F
//#2 = 3D9AE3F7 – Forward
//3# = 6182021B
//4# = 8C22657B – Left
//6 = 449E79F – Right // 16734885, backwards
//8 = 1BC0157B – Backwards
// /*