Mr.robot vr-1.0 (2013)
Sunday, August 23, 2015This is my robot for many purposes ,made using arduino and some other sensors. This robot can function as obstacle avoider, bluetooth controlled robot etc. it sense fire ,smoke,gas and any of them detected it make alarm sound. We can use this robot in home for security and use as pet.
Let's start making
Parts you need -
![]() |
Arduino |
![]() |
Circuits like fire alarm etc |
![]() |
Arduino |
![]() |
l293d motor controller |
![]() |
Hc-sr06 |
![]() |
Motor |

![]() |
Some plastic tins |

Some pics on making this
![]() |
Adding ldr alarm system alarm |
![]() |
Adding smoke alarm |
![]() |
Adding fire alarm |
![]() |
Adding fm transmitter |
![]() |
Adding main parts like arduino board |

![]() |
Adding ultra sonic sensor |
![]() |
before spray painting |
Arduino main code
//Libraries
#include <AFMotor.h>
//Objects
AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motorLeft(3, MOTOR12_64KHZ); // create motor #3, 64KHz pwm
//Constants and variable
char dataIn = 'S';
char determinant;
char det;
int vel = 0; //Bluetooth Stuff
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
//Initalization messages
Serial.println("ArduinoBymyself - ROVERBot");
Serial.println(" AF Motor test!");
//turn off motors
motorRight.setSpeed(0);
motorLeft.setSpeed(0);
motorRight.run(RELEASE);
motorLeft.run(RELEASE);
}
void loop() {
det = check(); //call check() subrotine to get the serial code
//serial code analysis
switch (det){
case 'F': // F, move forward
motorRight.setSpeed(vel);
motorLeft.setSpeed(vel);
motorRight.run(FORWARD);
motorLeft.run(FORWARD);
det = check();
break;
case 'B': // B, move back
motorRight.setSpeed(vel);
motorLeft.setSpeed(vel);
motorRight.run(BACKWARD);
motorLeft.run(BACKWARD);
det = check();
break;
case 'L':// L, move wheels left
motorRight.setSpeed(vel);
motorLeft.setSpeed(vel/4);
motorRight.run(FORWARD);
motorLeft.run(FORWARD);
det = check();
break;
case 'R': // R, move wheels right
motorRight.setSpeed(vel/4);
motorLeft.setSpeed(vel);
motorRight.run(FORWARD);
motorLeft.run(FORWARD);
det = check();
break;
case 'I': // I, turn right forward
motorRight.setSpeed(vel/2);
motorLeft.setSpeed(vel);
motorRight.run(FORWARD);
motorLeft.run(FORWARD);
det = check();
break;
case 'J': // J, turn right back
motorRight.setSpeed(vel/2);
motorLeft.setSpeed(vel);
motorRight.run(BACKWARD);
motorLeft.run(BACKWARD);
det = check();
break;
case 'G': // G, turn left forward
motorRight.setSpeed(vel);
motorLeft.setSpeed(vel/2);
motorRight.run(FORWARD);
motorLeft.run(FORWARD);
det = check();
break;
case 'H': // H, turn left back
motorRight.setSpeed(vel);
motorLeft.setSpeed(vel/2);
motorRight.run(BACKWARD);
motorLeft.run(BACKWARD);
det = check();
break;
case 'S': // S, stop
motorRight.setSpeed(vel);
motorLeft.setSpeed(vel);
motorRight.run(RELEASE);
motorLeft.run(RELEASE);
det = check();
break;
}
}
//get bluetooth code received from serial port
int check(){
if (Serial.available() > 0){// if there is valid data in the serial port
dataIn = Serial.read();// stores data into a varialbe
//check the code
if (dataIn == 'F'){//Forward
determinant = 'F';
}
else if (dataIn == 'B'){//Backward
determinant = 'B';
}
else if (dataIn == 'L'){//Left
determinant = 'L';
}
else if (dataIn == 'R'){//Right
determinant = 'R';
}
else if (dataIn == 'I'){//Froward Right
determinant = 'I';
}
else if (dataIn == 'J'){//Backward Right
determinant = 'J';
}
else if (dataIn == 'G'){//Forward Left
determinant = 'G';
}
else if (dataIn == 'H'){//Backward Left
determinant = 'H';
}
else if (dataIn == 'S'){//Stop
determinant = 'S';
}
else if (dataIn == '0'){//Speed 0
vel = 0;
}
else if (dataIn == '1'){//Speed 25
vel = 25;
}
else if (dataIn == '2'){//Speed 50
vel = 50;
}
else if (dataIn == '3'){//Speed 75
vel = 75;
}
else if (dataIn == '4'){//Speed 100
vel = 100;
}
else if (dataIn == '5'){//Speed 125
vel = 125;
}
else if (dataIn == '6'){//Speed 150
vel = 150;
}
else if (dataIn == '7'){//Speed 175
vel = 175;
}
else if (dataIn == '8'){//Speed 200
vel = 200;
}
else if (dataIn == '9'){//Speed 225
vel = 225;
}
else if (dataIn == 'q'){//Speed 255
vel = 255;
}
else if (dataIn == 'U'){//Back Lights On
determinant = 'U';
}
else if (dataIn == 'u'){//Back Lights Off
determinant = 'u';
}
else if (dataIn == 'W'){//Front Lights On
determinant = 'W';
}
else if (dataIn == 'w'){//Front Lights Off
determinant = 'w';
}
else if (dataIn == 'V'){//Horn On
determinant = 'V';
}
else if (dataIn == 'v'){//Horn Off
determinant = 'v';
}
else if (dataIn == 'X'){//Extra On
determinant = 'X';
}
else if (dataIn == 'x'){//Extra Off
determinant = 'x';
}
}
return determinant;
}
Click here Android app used to control the robot
Arduino obstacle avoider code
#include <AFMotor.h> //import your motor shield library
#define trigPin 14 // define the pins of your sensor
#define echoPin 15
AF_DCMotor motor1(1,MOTOR12_64KHZ); // set up motors.
AF_DCMotor motor2(3, MOTOR12_8KHZ);
void setup() {
Serial.begin(9600); // begin serial communitication
Serial.println("Motor test!");
pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
motor1.setSpeed(230); //set the speed of the motors, between 0-255
motor2.setSpeed (255);
}
void loop() {
long duration, distance; // start the scan
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // delays are required for a succesful sensor operation.
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); //this delay is required as well!
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;// convert the distance to centimeters.
if (distance < 45)/*if there's an obstacle 25 centimers, ahead, do the following: */ {
Serial.println ("Close Obstacle detected!" );
Serial.println ("Obstacle Details:");
Serial.print ("Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!");// print out the distance in centimeters.
Serial.println (" The obstacle is declared a threat due to close distance. ");
Serial.println (" Turning !");
motor1.run(FORWARD); // Turn as long as there's an obstacle ahead.
motor2.run (BACKWARD);
}
else {
Serial.println ("No obstacle detected. going forward");
delay (15);
motor1.run(FORWARD); //if there's no obstacle ahead, Go Forward!
motor2.run(FORWARD);
}
}
1 comments
I like your project
ReplyDeleteClick on 'Notify me' to get replies of your comment.