Let's Make Robots!

lithium polymer rover

Navigate around via ultrasound

right now all it does is avoid obstacles, but i hope to program it to have other functions.  

it has two hacked servos for motors, link to tutorial https://www.youtube.com/watch?v=q-kYpxTF1bo

 a us-100 ping sensor for navigation. 

And for power a 10000mha 5v lithium polymer battery that i pulled from a portable USB charger. It can run this robot for 8.5+ hours on a single charge.  

Wiring 

arduino pin 3 to trigger pin on ping sensor  

 arduino pin 4 to echo pin on ping sensor 

arduino pin 9 to servo

 

arduino pin 8 to servo

 

the code has been tested on arduino pro and should work on arduino uno if you change pin 8 to pin 10 in the code and wiring 

#include <Servo.h> 

 Servo myservo2;  // create servo object to control a servo 

 Servo myservo1;  // create servo object to control a servo 

void setup() {

  myservo1.attach(9);  

    myservo2.attach(8); // pin 10 for arduino uno 

 

  Serial.begin(9600);

 

}

 

void loop()

{

 

 

  long duration, inches, cm;

 

  pinMode(3, OUTPUT);

  digitalWrite(3, LOW);

  delayMicroseconds(2);

  digitalWrite(3, HIGH);

  delayMicroseconds(5);

  digitalWrite(3, LOW);

 

  pinMode (4, INPUT);

  duration = pulseIn(4, HIGH);

 

  cm = microsecondsToCentimeters(duration);

 

  Serial.print(cm);

  Serial.print("cm");

  Serial.println();

 

  delay(100);

 

if(cm<15)

{

  myservo1.write(180);      

    myservo2.write(180);    

  delay(200);  

}

 

else if(cm<10)

{

  myservo1.write(180);      

    myservo2.write(0);    

  delay(100);  

}

 

 

else

{

 myservo1.write(0);      

    myservo2.write(180);    

}

}

 

 

long microsecondsToCentimeters(long microseconds)

{

   return microseconds / 29 / 2;

}

Comment viewing options

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

10000 mAh !!!!! Oh great !! Nice obstacle avoider.