Let's Make Robots!

My very first robot. aka STINKBOT

Drives around bumping into objects making the room smell great
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.

I love everything about this bot. Great Job!

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!

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.

great job and thanks for showing the code!