Arduino autonomous robot - BennyStruktor 1 (a cat toy!)

The cat wants toys. Cool toys! A video of the toy!



How to do it:

Let´s print a robot chassi:

And a holder for the ultransonic sensor:

Get some servos! Futuba S3003. Nice ones! But they do not turn 360 degrees. Let´s modify it: (hack away the mechanical part that stops it from going around and disengage the internal potentiometer, set it to 50 %).

Mount the stuff! Connect to the Arduino board as shown in the image.

Add simple power from a 9 Volt battery.

Then some simple code. When something is too close, one wheel reverse direction and makes the robot turn. Do not forget to find the corredt libraries.

 * BennyStruktor 1
 * A cat toy
 * */

#include <NewPing.h> // for the ultrasonic sensor
#include <Servo.h>  // for the servos

// Settings of the ultrasonic sensor
#define TRIGGER_PIN 11
#define ECHO_PIN 12
#define MAX_DISTANCE 200

// init some servos
Servo LeftServo; 
Servo RightServo;

// init the ultrasonic sensor 
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() 

   // hook up the servos
void loop() 
  delay(200); // wait a little
  unsigned int uS = sonar.ping_cm(); // read the distance
  if(uS < 5) 
    // Something is detected less than 5 cm in front of the robot. Turn!  
      LeftServo.write(170); // one wheel goes in opposite direction
    // No obstacles! Proceed forward
    LeftServo.write(170); // both wheels turn forward