Marc Solc
Published

Desk Roomba

A handheld vacuum on wheels that will clean my desk when I finish my homework.

BeginnerFull instructions provided3 hours113
Desk Roomba

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Micro Servo 9g (S51)
×1
Continuous Servo FS90R
×4
Photo resistor
Photo resistor
×1
Wheel
Wheels that fit a FS90R Continuous Servo
×4
External Power Cord
An external power cord that can be used to supply 5V power to the photon.
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Tape, Clear
Tape, Clear
Hot glue gun (generic)
Hot glue gun (generic)
Card Board
Toothpick

Story

Read more

Schematics

Wiring

External power is what's sticking out with the white and blue wire. Connect the positive end to the positive rail and the negative end to the negative rail. A wire should go from the positive rail to VUSB. Each of the five servos and the photocell have three wires attached to them. One for power, one for ground, and one for information. Connect the power wires to the positive rail, the ground wires to the negative rail, and the information wires to the corresponding pins on the photon based on the code.

Code

Desk Roomba Code

C/C++
This code will tell my desk roomba to clean only if I turn on my desk light, then turn it off. A boolean flag is used to track the state of the light so that the vacuum doesn't keep running in the dark.
Servo leftFront; //wheel titles
Servo rightFront;
Servo leftBack;
Servo rightBack;

Servo powerButtonServo; //to push the power button

int analogPin = A1; //information from sensor
int val = 0;
bool lightOn = false; //flag

void setup()
{
    pinMode(analogPin, INPUT);
  	Serial.begin(9600);
  	
  	leftFront.attach(MOSI);
  	rightFront.attach(A2);
    leftBack.attach(D1);
  	rightBack.attach(MISO);
  	
  	powerButtonServo.attach(A5);
	
}

void loop()
{
    // read the photocell
    val = analogRead(analogPin);
    
    Particle.publish(String(val)); //printing values for debugging
    delay(500);
    
    //if the light is on, lightOn will become true
    if(val > 300)
    {
        lightOn = true;
        delay(1000);
    }
    
    //if the light is "on", then turns off, the robot will run
    if(lightOn && val < 300)
    {
        powerButtonServo.write(72); //push power button
        delay(1000);
        powerButtonServo.write(60); //pull away
        delay(100);
        
        lightOn = false; //reset the flag
        
        //forwards
        leftFront.write(103);
        rightFront.write(70); //flipped
        leftBack.write(101);
        rightBack.write(70); //flipped
        delay(1000);
        
        //stop
        leftFront.write(90);
        rightFront.write(90);
        leftBack.write(90);
        rightBack.write(90);
        delay(10);
        
        //backwards
        leftFront.write(69);
        rightFront.write(100);
        leftBack.write(72);
        rightBack.write(100);
        delay(1200);
          
        //turn left (right wheels faster)
        leftFront.write(90);
        rightFront.write(0);
        leftBack.write(90);
        rightBack.write(0);
        delay(500);
        
        //forwards
        leftFront.write(105);
        rightFront.write(68);
        leftBack.write(105);
        rightBack.write(68);
        delay(1000);
        
        //backwards
        leftFront.write(70);
        rightFront.write(100);
        leftBack.write(70);
        rightBack.write(100);
        delay(1000);
	    
	      //straighten up
        rightFront.write(180);
        leftBack.write(180);
        delay(350);
        
        //backwards
        leftFront.write(74);
	      rightFront.write(100);
        leftBack.write(74);
        rightBack.write(100);
        delay(475);
        
        //stop
        leftFront.write(90);
	      rightFront.write(90);
        leftBack.write(90);
        rightBack.write(90);
	    
	      powerButtonServo.write(70);
        delay(1000);
        powerButtonServo.write(60);
        
    }
}

Credits

Marc Solc
2 projects • 0 followers

Comments