Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Mohit SenapatiLokesh KharidhiVaishnaviDhavalashri PrasadPriya C
Published © CERN-OHL2

Roboboi - The intelligent UV sanitization Robot

Roboboi, where smartness meets innovation to keep you safe 24/7

IntermediateFull instructions providedOver 8 days1,125
Roboboi - The intelligent UV sanitization Robot

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×2
Servo Module (Generic)
×1
DC motor (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×1
SparkFun Full-Bridge Motor Driver Breakout - L298N
SparkFun Full-Bridge Motor Driver Breakout - L298N
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
×2
Zener Single Diode, 11 V
Zener Single Diode, 11 V
×4
Capacitor 100 µF
Capacitor 100 µF
×1
resistors - assorted
×1
Resistor 10k ohm
Resistor 10k ohm
×1
LED (generic)
LED (generic)
×4
pneumatic wheel
×2
Caster wheel
×1
Battery LC-P12200BP
×1
Hardware, Screw & Clip Nut
Hardware, Screw & Clip Nut
×2
aluminium rod
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fusion
Autodesk Fusion
SolidWorks

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)
Hot glue gun (generic)
Hot glue gun (generic)
Multitool, Screwdriver
Multitool, Screwdriver
Helping Hand Tool, with Magnifying Glass
Helping Hand Tool, with Magnifying Glass
Drill / Driver, Cordless
Drill / Driver, Cordless
spanner

Story

Read more

Custom parts and enclosures

Cad file1

Cad file2

Schematics

body_v12_S2W61ZNVWc.step

swivel_caster_wheel_v3_x7Pv2m2jCg.step

tires_v3_VoyEjUYIkq.step

uv_lamp_v1_k9sxKAI7H5.step

battery_indicator_XRCLauVgl1.jpeg

cover_uGsW9695a3.png

robot_WUuoyFwaO8.jpeg

roboboi_aQY7VmpQxN.jpeg

roboboi1_UcctgHYwHS.jpeg

Bill of Materials

Roboboi

Code

Arduino Movement

C/C++
Movement with obstacle detection
//AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install //
//NewPing Library https://github.com/livetronic/Arduino-NewPing//
//Servo Library https://github.com/arduino-libraries/Servo.git //
#include <AFMotor.h>
#include <NewPing.h>
#include <Servo.h>
#define TRIG_PIN A0
#define ECHO_PIN A1
#define MAX_DISTANCE 200
#define MAX_SPEED 30 // sets speed of DC motors
#define MAX_SPEED_OFFSET 5
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);
AF_DCMotor motor1(1, MOTOR12);
AF_DCMotor motor2(2, MOTOR12);
AF_DCMotor motor3(3, MOTOR34);
AF_DCMotor motor4(4, MOTOR34);
Servo myservo;
boolean goesForward=false;
int distance = 100;
int speedSet = 0;
void setup() {
 myservo.attach(10);
 myservo.write(115);
 delay(1750);
 distance = readPing();
 delay(300);
 distance = readPing();
 delay(300);
 distance = readPing();
 delay(300);
 distance = readPing();
 delay(300);
}
void loop() {
int distanceR = 0;
int distanceL = 0;
delay(60);
if(distance<=30)
{
 moveStop();
 delay(200);
 moveBackward();
 delay(500);
 moveStop();
 delay(500);
 distanceR = lookRight();
 delay(500);
 distanceL = lookLeft();
 delay(500);
 if(distanceR>=distanceL)
 {
 turnRight();
 moveStop();
 }else
 {
 turnLeft();
 moveStop();
 }
}else
{
 moveForward();
}
distance = readPing();
}
int lookRight()
{
 myservo.write(50);
 delay(600);
 int distance = readPing();
 delay(80);
 myservo.write(115);
 return distance;
}
int lookLeft()
{
 myservo.write(170);
 delay(600);
 int distance = readPing();
 delay(80);
 myservo.write(115);
 return distance;
 delay(50);
}
int readPing() {
 delay(100);
 int cm = sonar.ping_cm();
 if(cm==0)
 {
 cm = 250;
 }
 return cm;
}
void moveStop() {
 motor1.run(RELEASE);
 motor2.run(RELEASE);
 motor3.run(RELEASE);
 motor4.run(RELEASE);
 }

void moveForward() {
if(!goesForward)
 {
 goesForward=true;
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
 for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=1)
 {
 motor1.setSpeed(speedSet);
 motor2.setSpeed(speedSet);
 motor3.setSpeed(speedSet);
 motor4.setSpeed(speedSet);
 delay(10);
 }
 }
}
void moveBackward() {
 goesForward=false;
 motor1.run(BACKWARD);
 motor2.run(BACKWARD);
 motor3.run(BACKWARD);
 motor4.run(BACKWARD);
 for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=1)
 {
 motor1.setSpeed(speedSet);
 motor2.setSpeed(speedSet);
 motor3.setSpeed(speedSet);
 motor4.setSpeed(speedSet);
 delay(10);
 }
}
void turnRight() {
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(BACKWARD);
 motor4.run(BACKWARD);
 delay(600);
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
}
void turnLeft() {
 motor1.run(BACKWARD);
 motor2.run(BACKWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
 delay(600);
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
} 

Arduino Mapping

C/C++
Maps the room for movement of the Roboboi
#include "Servo.h"

// Motors
Servo motor1;
Servo motor2;

// Rotary Encoders
int encoderAPin = 4;              //Left      // pin for the rotary encoderA
int encoderBPin = 2;              //Right     // pin for the rotary encoderB
int encoderAPosition = 0;                     // position counter for encoderA
int encoderBPosition = 0;                     // position counter for encoderB
int signalAInput1;                             // signal input 1 for encoderA
int signalAInput2;                             // signal input 2 for encoderA
int signalBInput1;                             // signal input 1 for encoderB
int signalBInput2;                             // signal input 2 for encoderB



// robot location service
// 0 is up
// 1 is right
// 2 is down
// 3 is left
int robotDirection = 2;

// this is the coordinates in the grid of where the robot is
// it is also the x and y indexes in the array.
// remember that the array starts at index 0.
int xcoordinate = 2;
int ycoordinate = 1;

// ultrasonic pins
const int Trig_pin =  5;  // pin for triggering pulse    INPUT
const int Echo_pin = 6;   // pin for recieving echo      OUPUT
long duration;            // how long it takes for the sound to rebound


// motor pins
const int Motor1Pin = 9;  // Left side
const int Motor2Pin = 10; // right side

// the array that it tracks with
// this can be an array of any size
// just make sure that the robot has a free space to move to from its initial position.
int arraything [6] [6] =
{ 
  {    1,1,1,1,1,1    }
  ,
  {    1,1,0,1,0,1    }
  ,
  {    1,1,0,1,0,1    }
  ,
  {    1,1,0,1,0,1    }
  ,
  {    1,1,0,1,1,1    }
  ,
  {    1,1,1,0,1,1    }
};



void setup () {
  // Rotary encoder
  pinMode (encoderAPin, INPUT);
  pinMode (encoderBPin, INPUT);
  Serial.begin(9600);
  Serial.println ("Starting now...");
  \

  // ultrasonic
  //  pinMode(Trig_pin, OUTPUT);        // initialize the pulse pin as output:
  //  pinMode(Echo_pin, INPUT);       // initialize the echo_pin pin as an input:


  // motorsmmmmmmmmm
  motor1.attach(Motor1Pin);
  motor2.attach(Motor2Pin);

}


// In English, this program sees if there is something in front of it.
// If no, it moves straight. If yes, it checks its Right.
// If its Right is free, it turns that way, or else, it checks its Left.
// If its Left is free, it turns that way, or else, it just turns 180 degrees
// and goes back the way it came.
//
// Next to do is to encorporate beginning and destination as well as optimum path finding
//
// Last is to use the ultrasonic with the grid.

void loop () {

  while (1==1){
    if (isFrontOpen() == true) {
      moveForward();
      delay (2000);
    }
    else
      if (isRightOpen() == true) {
      turnRight();
      delay (2000);
    }
    else
      if (isLeftOpen() == true) {
        turnLeft();
        delay (2000);
      } 
      else {
        turnAround();
        delay (2000);
      }
  }
}


// Checks if there is something right in front of it using Grids
boolean isFrontOpen () {
  int nextNumber = getFrontNumber();
  if (nextNumber == 0){
    return true;
  }
  else {
    return false;
  }
}

// Checks if there is something to the Right of it using Grids
boolean isRightOpen(){
  int nextNumber = getRightNumber();
  if (nextNumber == 0){
    return true;
  }
  else {
    return false;
  }
}

// Checks if there is something to the Left of it using Grids
boolean isLeftOpen(){
  int nextNumber = getLeftNumber();
  if (nextNumber == 0){
    return true;
  }
  else {
    return false;
  }
}


// Moves straight forward.
void moveForward () {
  motor1.write(180);
  motor2.write(0);

  Serial.println("Forward");
  if (robotDirection == 0)
    ycoordinate = ycoordinate - 1;
  if (robotDirection == 1)
    xcoordinate = xcoordinate + 1;
  if (robotDirection == 2)
    ycoordinate = ycoordinate + 1;
  if (robotDirection == 3)
    xcoordinate = xcoordinate - 1;
  delay (100);
  /*Serial.print("  xcoordinate " );
   Serial.print(xcoordinate);
   delay (500);
   Serial.print(" ycoordinate ");
   Serial.print(ycoordinate);
   delay (500);
   Serial.print("  robot direction: ");
   Serial.print(robotDirection);
   delay(500);
   Serial.println ();
   delay(1000);

   */
  delay(800);
}

// Turns 90 degrees to the Right
void turnRight () {
  motor1.write (60);
  motor2.write (60);
  delay(178);
  motor2.write(95) ;
  delay(65) ;
  motor1.write(90);
  Serial.println("Right");
  if (robotDirection == 0)
    robotDirection = 1;
  else if (robotDirection == 1)
    robotDirection = 2;
  else if (robotDirection == 2)
    robotDirection = 3;
  else if (robotDirection == 3)
    robotDirection = 0;
  delay (500);
  Serial.print("  xcoordinate " );
  Serial.print(xcoordinate);
  delay (500);
  Serial.print(" ycoordinate ");
  Serial.print(ycoordinate);
  delay (500);
  Serial.print("  robot direction: ");
  Serial.print(robotDirection);
  delay (500);
  Serial.println();

  delay(1000);
}


// Turns 90 degrees to the Left
void turnLeft () {
  motor1.write(120);
  motor2.write(120);
  delay(325);
  motor2.write(95) ;
  delay(65) ;
  motor1.write(90);
  Serial.println("Left");
  if (robotDirection == 0)
    robotDirection = 3;
  else if (robotDirection == 1)
    robotDirection = 0;
  else if (robotDirection == 2)
    robotDirection = 1;
  else if (robotDirection == 3)
    robotDirection = 2;
  delay (500);
  Serial.print("  xcoordinate " );
  Serial.print(xcoordinate);
  delay (500);
  Serial.print(" ycoordinate ");
  Serial.print(ycoordinate);
  delay (500);
  Serial.print("  robot direction: ");
  Serial.print(robotDirection);
  delay(500);
  Serial.println();
  delay(1000);
}


// Turns 180 degrees
void turnAround () {
  //  delay(1000);
  Serial.println("Around");
  if (robotDirection == 0)
    robotDirection = 2;
  else if (robotDirection == 1)
    robotDirection = 3;
  else if (robotDirection == 2)
    robotDirection = 0;
  else if (robotDirection == 3)
    robotDirection = 1;
  delay (500);
  Serial.print("  xcoordinate " );
  Serial.print(xcoordinate);
  delay (500);
  Serial.print(" ycoordinate ");
  Serial.print(ycoordinate);
  delay (500);
  Serial.print("  robot direction: ");
  Serial.print(robotDirection);
  delay(500);
  Serial.println();

  delay(1000);
}


// Gets the number on the Grid of the space right in front of it.
int getFrontNumber() {
  if (robotDirection == 0) {
    return arraything  [ycoordinate - 1][xcoordinate];
  }
  if (robotDirection == 1)  {
    return arraything  [ycoordinate][xcoordinate + 1];
  }
  if (robotDirection == 2) {
    return arraything [ycoordinate + 1][xcoordinate] ;
  }
  if (robotDirection == 3) {
    return arraything  [ycoordinate][xcoordinate - 1];
  }
}


// Gets the number on the Grid of the space to the Right of it.
int getRightNumber() {
  if (robotDirection == 0) {
    return arraything [ycoordinate][xcoordinate + 1] ;

  }
  if (robotDirection == 1)  {
    return arraything  [ycoordinate + 1][xcoordinate];

  }
  if (robotDirection == 2) {
    return arraything  [ycoordinate][xcoordinate - 1];
  }
  if (robotDirection == 3) {
    return arraything  [ycoordinate - 1][xcoordinate];
  }
}


// Gets the number on the Grid of the Space to the Left of it.
int getLeftNumber() {
  if (robotDirection == 0) {
    return arraything [ycoordinate][xcoordinate - 1] ;
  }
  if (robotDirection == 1)  {
    return arraything  [ycoordinate - 1][xcoordinate];
  }
  if (robotDirection == 2) {
    return arraything [ycoordinate][xcoordinate + 1] ;
  }
  if (robotDirection == 3) {
    return arraything  [ycoordinate + 1][xcoordinate];
  }
}

Arduino Code for battery Indicator

C/C++
Show Battery Level
int analogInput = 0;
int f=2;
int e=3;
int d=4;
int c=5;
int b=6;
int a=7;
int s=13;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000;
float R2 = 10000;
int value = 0;
void setup()
{
Serial.begin(9600);
pinMode(analogInput,INPUT);
pinMode(s,OUTPUT);
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
digitalWrite(s,LOW);
digitalWrite(a,HIGH);
delay(500);
digitalWrite(b,HIGH);
delay(500);
digitalWrite(c,HIGH);
delay(500);
digitalWrite(d,HIGH);
delay(500);
digitalWrite(e,HIGH);
delay(500);
digitalWrite(f,HIGH);
delay(500);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
}
void loop()
{
value = analogRead(analogInput);
vout = (value * 5.0) / 1024;
vin = vout / (R2/(R1+R2));
Serial.println("Input Voltage = ");
Serial.println(vin);
if(vin>12.46) {digitalWrite(a,HIGH);}
else { digitalWrite(a,LOW);}
if(vin<=12.46 && vin>12.28) {digitalWrite(b,HIGH);}
else { digitalWrite(b,LOW);}
if(vin<=12.28 && vin>12.12) {digitalWrite(c,HIGH);}
else { digitalWrite(c,LOW);}
if(vin<=12.12 && vin>11.98) {digitalWrite(d,HIGH);}
else { digitalWrite(d,LOW);}
if(vin<=11.98 && vin>11.90){digitalWrite(e,HIGH);}
else {digitalWrite(e,LOW);}
if(vin<=11.90) {digitalWrite(f,HIGH);}
else {digitalWrite(f,LOW);}
delay(2000);
}

Credits

Mohit Senapati

Mohit Senapati

5 projects • 4 followers
Lokesh Kharidhi

Lokesh Kharidhi

1 project • 4 followers
Vaishnavi

Vaishnavi

1 project • 4 followers
Dhavalashri Prasad

Dhavalashri Prasad

1 project • 3 followers
Priya C

Priya C

0 projects • 1 follower
Thanks to ASTARKFUTURE.

Comments