Floor-Cleaning Robot

I created a floor cleaning robot using a car chassis as the base. Using a l298N motor controller and an Arduino it allows it to cleaning the floors thoroughly and accurately.

Engineer

Jacob G

Area of Interest

Mechanical Engineering

School

Monta Vista High School

Grade

Incoming Sophmore

Demo Night

I am really proud of myself and what I did over the past 3 weeks. I was really impressed with myself that I was able to create this robot in a short period of time. My experience at BlueStamp opens up a lot more engineering opportunities in the future and is cementing my dream in becoming a mechanical engineer.

Final Milestone

My final milestone for the floor cleaning robot was to rewire all the wires on my chassis, connect the sensor on to my robot, and finally to add the vacuum to the robot. The first step was to solder the wires from the switch and the two motors back to the L298n motor controller. After I had completed the step I added the ultrasonic sensor. The code I used was once the robot is near an object it will stop in front of the object. I used velcro to attach the vacuum to the back of my robot so it is easily accessible. Once the code was tested and it successfully completed the task I had finished my second milestone. My next steps is to utilize the ultrasonic sensor and allow the robot to turn around once it is near an object.
code for finalMilestone

// Include the library
#include <L298N.h>
#include “SHCSR04.h”

SHCSR04 hcsr04;

// Pin definition
const unsigned int IN1 = 8;
const unsigned int IN2 = 7;
const unsigned int ENA = 9;
const unsigned int ENB = 6;
const unsigned int IN3 = 5;
const unsigned int IN4 = 4;

// Create one motor instance
L298N motor(ENA, IN1, IN2);
L298N motor2(ENB, IN3, IN4);
int turning=0;
void setup(){
motor.setSpeed(255);
motor2.setSpeed(255);
Serial.begin(115200);

}

void loop()
{
Serial.println(“——————-“);
Serial.print(“measure = “);
Serial.print(hcsr04.read(2, 3));
Serial.println(” cm”);
Serial.println();

if ((hcsr04.read(2,3))>10){
motor.forward();
motor2.forward();

delay(500);

motor.stop();
motor2.stop();

}

else if ((hcsr04.read(2,3))<10 and turning==0){

motor.backward();
motor2.forward();

delay(500);

motor.stop();
motor2.stop();

}

}

First Milestone

My first milestone was to finish assembling my chassis and connecting it to the L298N motor controller and to the Arduino. My first step was to first assembling the chassis. Afterward I took the L298N motor controller and wired it to the Arduino. After doing this I connected the wires from the L298N motor controller to the two motors at the bottom of my chassis. Afterward, I uploaded a code that allowed the chassis to go in a back and forth motion. After I had uploaded the code and saw that the chassis completed the task I finished my first milestone.
code for firstMilestone

// Include the library
#include <L298N.h>

// Pin definition
const unsigned int IN1 = 7;
const unsigned int IN2 = 8;
const unsigned int EN = 9;

// Create one motor instance
L298N motor(EN, IN1, IN2);

void setup()
{
// Used to display information
Serial.begin(9600);

// Wait for Serial Monitor to be opened
while (!Serial)
{
//do nothing
}

// Set initial speed
motor.setSpeed(70);
}

void loop()
{

// Tell the motor to go forward (may depend by your wiring)
motor.forward();

// Alternative method:
// motor.run(L298N::FORWARD);

//print the motor satus in the serial monitor
printSomeInfo();

delay(3000);

// Stop
motor.stop();

// Alternative method:
// motor.run(L298N::STOP);

printSomeInfo();

// Change speed
motor.setSpeed(255);

delay(3000);

// Tell the motor to go back (may depend by your wiring)
motor.backward();

// Alternative method:
// motor.run(L298N::BACKWARD);

printSomeInfo();

motor.setSpeed(120);

delay(3000);

// Stop
motor.stop();

printSomeInfo();

delay(3000);
}

/*
Print some informations in Serial Monitor
*/
void printSomeInfo()
{
Serial.print(“Motor is moving = “);
Serial.print(motor.isMoving());
Serial.print(” at speed = “);
Serial.println(motor.getSpeed());
}

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering