Introduction: Automated Gyro Wheel Toy

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.

I had a simple gyro wheel toy and decided I wanted to automate it. Took a single servo, attached it to an axle and attached the toy to the axle. Then made a simple magnetic switch with a ball point pen spring, hooked that and the servo to and Arduino Uno. The program is very short and simple. But I have future plans to make it more interesting. Stay tuned for Version 2 and 3.

Step 1:

Arduino Code:


#include
Servo servo1;

int servangle = 0;// servo angle variable

int potPin = 2; // select the input pin for the potentiometer

int ledPin = 13; // select the pin for the LED

//Analog read pins const

int buttonPin = 2;

void setup()

{ Serial.begin(9600);

pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT

pinMode(buttonPin,INPUT);

servo1.attach(9);

delay(1000);

servo1.write(90);

delay(5000);

servo1.write(172); }

void loop() {

if (digitalRead(buttonPin) == HIGH) {

digitalWrite(ledPin,HIGH);

servo1.write(90);

delay(1200);

servo1.write(172);

digitalWrite(ledPin,LOW);

}

}