My very first robot. aka STINKBOT
| Attachment | Size |
|---|---|
| Stinkbot_OAbeta1.pde | 1.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);
}
}
}













@ Thu, 2011-07-28 19:23
I love everything about this
I love everything about this bot. Great Job!
@ Thu, 2011-07-28 15:59
Very nice job with the air
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. :)
@ Thu, 2011-07-28 19:30
LOL
Awesome hack hehehe It looks like one of those luminary-type units. Any plans to add a light show to ol' Stinky here?
@ Thu, 2011-07-28 21:44
Its funny you say that. It
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
@ Sun, 2011-07-24 11:27
Mousel wheel
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!
@ Sun, 2011-07-24 10:12
Good start!Since it often
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.
@ Sat, 2011-07-23 23:34
great job and thanks for
great job and thanks for showing the code!