Let's Make Robots!

My very first robot. aka STINKBOT

AaahhhAndrew's picture
Drives around bumping into objects making the room smell great
Cost to build: 
$80
Time to build: 
8 hours
AttachmentSize
Stinkbot_OAbeta1.pde1.12 KB

I just finished my very first robot today. Not having a Ping ultrasonic sensor I searched my parts box for ideas on how to avoid objects. After having realized that I couldnt avoid objects I figured the bot could run into an object, it just needed a way to eventually get around it. I reused some mouse buttons, an Adafruit motor shield and an Arduino Uno. I also used a Precision mandrel bent self suspensioning paper clip/ mouse wheel combo lol ;P I call it Stinkbot because I used the base of a Febreeze airfreshener. This little guy just drives around making my house smell great :)

This is my first attempt at writing a code that controlled more than an Led.

**A little hint to other new people to this site. When selecting my embed code from youtube I had to select options and click "use old embed code" for the link to work correctly on here.

I was thinking that I may want to add some sort of button count so that if the bot gets stuck in a particular corner and the same button keeps getting pressed that the bot would just do a full 180 and continue on.

#include <AFMotor.h>

#define LB 14
#define RB 19
int lval = 0;
int rval = 0;

AF_DCMotor motor(3, MOTOR12_64KHZ);
AF_DCMotor motor1(4, MOTOR12_64KHZ);
void setup() {
  Serial.begin(9600);          
  Serial.println("Go Robot Go!");
 
  motor.setSpeed(200);
   motor1.setSpeed(255); 
  pinMode(LB, INPUT);
  pinMode(RB, INPUT);

}

void loop() {
  Serial.print("nomnomnom");
 
  motor.run(FORWARD);
  motor1.run(FORWARD); 
 
  {
  lval = digitalRead(LB);
  if (lval == HIGH)
  {
  Serial.print("Obstacle to the left! Reversing!");  
  motor.run(BACKWARD);
  motor1.run(BACKWARD);
  delay(500);
  motor.run(RELEASE);
  motor1.run(RELEASE);
  delay(250);
  motor1.run(BACKWARD);
  delay(750);
 
  }


  rval = digitalRead(RB);
  if (rval == HIGH) {
     Serial.print("Obstacle to the RIGHT! Reversing!");
    motor.run(BACKWARD);
  motor1.run(BACKWARD);  //
  delay(500);
  motor.run(RELEASE);
  motor1.run(RELEASE);
  delay(250);
  motor.run(BACKWARD);
  delay(750);
  }
}
  }

 

Photobucket Photobucket Photobucket Photobucket Photobucket Photobucket Photobucket Photobucket Photobucket

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
walkercreations's picture

I love everything about this bot. Great Job!

Humanoido's picture

Very nice job with the air fresh idea as a base. It would be cool if that working mechanism could be retained, then it could exchange scents at different times for different rooms. Lilac for Spring. Evergreen for summer. Not sure about winter. :)

JAX's picture

Awesome hack hehehe It looks like one of those luminary-type units. Any plans to add a light show to ol' Stinky here?

AaahhhAndrew's picture

Its funny you say that. It is a luminary type. I used it alot and was growing frustrated that I had to keep changing the batteries in it. My first hack was adding a plug from an old unused cellphone to the base so I could just leave it plugged in. Then I thought it would be cool to add different color leds to it. It has snowballed into what it is now. Planning on adding a gas sensor to it as a joke to my friends about not farting or the robot will chase them down LOL

mogul's picture

Damn I love the look of your "Precision mandrel bent self suspensioning paper clip/ mouse wheel combo"

I have a pile of scrapped mouses laying around some where, great wheels, I can see now!

OddBot's picture

Good start!

Since it often gets stuck in a corner depending on which switch gets hit first you might need to give it a rudementry memory. If the switches alternate repeatedly within a certain period of time then turn in one direction only regardless of which switch is pressed for the next 2 turns or until no switch has been pressed for more than a certain period of time.

Another simpler but less reliable way is to randomise the amount by which the robot turns each time a button is pressed. Perhaps if both buttons are pressed within a given period then turn 180 degrees.

mlandergan's picture

great job and thanks for showing the code!