Introduction: Push Rollbot

About: I am an American teaching English at Shangluo University, Shaanxi. I like making machines that do interesting but fairly useless things - I call them Quixotic Machines.

This is my push and roll robot made from a single servo, a tilt sensor (VTI SCA610 Inclinometer accelerometer) and an Arduino Uno. The second half of the video gives some details on how it works.

Here is Arduino program:

// Push rolling robot with single servo, tilt-sensor and Arduino Uno

// by Jim Demello 1/12/2015

#include

Servo myservo2;

int Forward = 1;

int rollCntr = 0;

int val; // variable to read the value from the analog pin

int gyroPin = 5; //tiltmeter VTI SCA610 inclinometer chip (gyro?)

int gyroVal = 0;

void setup()

{

myservo2.attach(9); // attach servo pin 9

myservo2.writeMicroseconds(1500); // center servo

delay(15);

Serial.begin(9600);

Serial.println("Program start...");

}

void loop()

{

val=90; //servo centered at 90 degrees

gyroVal = analogRead(gyroPin);

gyroVal = map(gyroVal, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)

delay(10);

if(rollCntr > 4) { if (Forward) {Forward = 0;} // reverse direction

else Forward = 1;

rollCntr = 0;}

if(Forward && (gyroVal > (val - 5) and gyroVal < (val +25 )))

{ myservo2.write(40); delay(500); myservo2.write(90); // go forward

rollCntr = rollCntr + 1;

}

if (!Forward && (gyroVal > (val - 25) and gyroVal < (val + 5 )))

{ myservo2.write(150); delay(500); myservo2.write(90); // go reverse

rollCntr = rollCntr + 1;

}

Serial.print(" level @ : ");Serial.print(val);Serial.print(" angle: ");Serial.print(gyroVal);

Serial.print(" Forward: ");Serial.println(rollCntr);

delay(40); //