Introduction: Mop Robot for the Wifey
to view all the posts i did on this robot, please check my g+ profile,
my original intention was to build a line follower robot, until my wife's household chore caught my attention. from then my focus was on creating a robot similar to roomba, minus the vacuum. :]
the original design was a bit of a bulky wiring, but it worked well, running only on a single 9V battery to power the arduino uno, motor shield, and an ir sensor. then i read through some posts that this was a bad idea so i had to split powers for the arduino and the motor shield, and the mop section also got gave up after bumping several times at high speeds.
the 2nd design had a flaw which i didn't think through. i placed all components on top of a flat plastic plate which meant that there was more surface area in contact with the ground. this meant more force from the motors to move it. failed.
Step 1: Parts List
these are the parts i collected to make this robot:
- arduino uno
- motor shield, or any motor driver (dfrduino motor shield)
- dc motor assembly, or any geared motor kits (i had the tamiya twin geared motors)
- 9v battery, and battery clip
- AAA batteries and holder (total voltage should be compatible for your motor driver, or shield)
- IR sensor
- nuts, bolts, aluminum mounting frames
- solid wires #22 gauge or smaller
- breadboard (small, if possible), for testing, and circuit adjustments.
- main body to hold everything together..i got a plant pot holder from DAISO for 2$
- pliers, soldering wire, soldering iron
- a lot of imagination :]
Step 2: Assembling the Components, and Parts
it's necessary that the main body for your robot be light but sturdy. after several tries on the design, i decided on a plant pot holder because of it's advantages. the downside is it was a bit heavier than the aluminum frames i first worked on. but i managed to compensate with the gear motor assembly because it can be adjusted to move fast or slow. so the result evened out. i have a fast-spinning geared motor assembly, but i had a heavier frame. the result was just the right speed. although, if you think about it, it's inefficient.
every component used here is an assembly in itself, the tamiya geared motors, arduino and motor shield, the IR diode sensor. so follow the instructions on how to put them together. once the individual parts are completed, work next on putting the whole assembly together.
this will have to have, at most, 3 sections that will touch the ground. what i did was have all components screwed to the underside of the main body, so they will be hanging down. on a typical robot with motors, there will usually be 3 portions that will touch the ground; 2 wheels and a ballcaster. here, since it's a mop, the 3rd ground contact is a mop contraption. its basically a small piece of board where you can clip a small piece of tissue. my first version used a plastic chocolate container which is then screwed to the underside of the contraption. check this link;
the current version uses a small aluminum strip where i attach the tissue.
Step 3: Putting Everything Together
parts placement is important; the wheel on geared motor assembly would have to be centered on the round plant pot, since this will be in contact with the ground. it's like a seesaw..once the motors move forward, the whole robot will tilt forward, so the weight will be on the mop/tissue.
on the attached image, the center block is a small breadboard which can be hidden or placed elsewhere convenient. please take note that the placement of parts will add to your robot's weight, and balance. i've placed the batteries forward, since i need more weight on the front, to press down on the mop section. the arduino and shield are at the rear, to counter balance.
a side note on the IR sensor; to increase the sensitivity wrap a black electrical tape around it to form a tube pointing forward. this will help to eliminate ambient light in the surrounding from interfering with the diode sensor's readings. it did help me when i can't read anything right from the sensors.
once the component placement has been planned, let's go to wiring.
Step 4: Wiring Things Together
there's a lot to be learned from arduinos, and it won't fit this instructable, so read as much as you can before heading on to the actual wiring. this is where you need to use the bread board, to test things out before finalizing your connections on the robot.
first on the arduino. there is a power terminal on the arduino that lets you supply 9V on it. this power connection has a set of regulators and makes sure that what goes to the IC is a safe 5V. you can then tap from the 5V pin to power your IR sensor. the IR sensor has 3 pins, vcc, ground, and an output pin. how it works is whenever it senses an obstacle, the sensor picks up more light, and will give a corresponding voltage, which we will detect from pin A1 on the arduino. so connect the output pin from the sensor to pin A1 on the arduino/shield.
on the motor shield; you need to make sure to read a lot on the manuals for your motor shield. i ended up smoking the arduino one time because i misread the pin labels on the shield. some considered it best practice to separate the supply for the motor shield from your arduino, that's why i have a 9V supply for the arduino, and a 4.6V supply for the motor shield, and motors. also, do not use a 9V battery for the motor shield, it has less power, and won't last long. you can feed the + voltage from the batteries to a DPDT switch. output goes to the respective +vcc pins for the arduino and the motorshield.
to connect to the motors; the motor shield has 4 pins going out from it; M1+,M1-,M2+,M2-. connect these directly to the motors M1,M2. Some DC motors won't have +,- labelled on them, that's fine. We can determine them from code later.
you need to try the connections first on the breadboard, before putting them on the robot. be careful with the ground, and positive connections, especially on the arduino. i can't explain how scary it is to see your board emitting smoke :D
Step 5: Arduino Code.
how the code works is at the beginning of the loop we check for the value on the sensor, and then decide if we need to move forward, or turn. it's going to require some test on the actual values required to decide whether it's a bump or clear. also, check on the documentation for the motor shield, as to which pins are assigned for the motor control pin, and pwm pins. pwm determines what voltage should be fed to your motors, and control sets whether the motor should be High, or Low. On, and Off, respectively.
I'm using the code below. modify M1,M2,E1,E2, according to the pin assignments for your shield, and sensor_max,sensor_min according to your IR sensor value when there's an obstruction. also, under the method, forward_motors(), there is a line, digitalWrite(M1,LOW); and digitalWrite(M2,LOW); ...modify LOW, to HIGH, if the motors are spinning backwards. do the opposite for reverse_motors() method.
random spin delay, random reverse delay, random
1.on first boot, do a read sequence, spin 10times and check average.
2.run forward on 50counts, then reboot.
int in1 = A4; //input pin
int led1 = 12; //blink led - signals
//int resetpin = 12;
int M1 = 7;
int M2 = 4;
int E1 = 6; //left motor
int E2 = 5; //right motor
int fspd = 255; //forward slowed down speed
int mspd = 255; //normal motor speed
int ddelay = 0;
int icount = 0;
int count_limit = 35;
int min_delay = 250;
int max_spin_delay = 550;
int max_rev_delay = 500;
int sensor_max = 60;
//int sensor_min = 69;
int sensor_min = 20;
int sensor_val = 0;
void loop() //main loop sequence
ddelay = 0;
sensor_val = 0;
sensor_val = analogRead(A1);
if (sensor_val > sensor_min)
icount = 0;
count_limit = rand(35,50);
if (icount > 50)
icount = 0;
count_limit = rand(35,50);
//slowdown motor? or stop motor?
ddelay = rand(min_delay,max_rev_delay);
ddelay = rand(min_delay,max_spin_delay);
analogWrite(E1,fspd); //PWM Speed Control
analogWrite(E2,fspd); //PWM Speed Control
analogWrite(E1,mspd); //PWM Speed Control
analogWrite(E2,mspd); //PWM Speed Control
void turn_motor() //turn right?
analogWrite(E1,0); //PWM Speed Control
analogWrite(E2,fspd); //PWM Speed Control
int rand(int mini, int maxi) //random values
int randval = random(mini,maxi);
the arduino ide has a nifty feature that can monitor the values you wish to display,
just connect the usb cable on the arduino and the pc, on the arduino, click on
tools > serial monitor. and you will get all the values spewed out with the Println() lines
from the code above.
Step 6: If Everything Went Well..
it should run.. :]
if it didn't, something went wrong..backtrack on the connections, and see what's wrong. as long as there's no smoke, we should be fine. hehe..we just need to make sure the connections are correct. also, it would depend on the sensors output. try lowering the sensor_max, to see if something happens.
the mop is able to pickup a lot of dirt, but it becomes a problem when it's stuck under a small clearing. it often gets stuck. perhaps we can add a limit switch on the top that triggers the reverse when hit.
thanks for looking into this instructable :]