Luo Yi Tan – Assignment 10 Automaton

It’s a rather unhappy cat looking at a bird.

Since it was the first time I was making something like this, I wanted to make it simple. At first I just wanted a mechanism to make a figure move back and forth in a linear way. I wanted to use a cam, but needed full rotation to do so, and my DC motor had problems, like not spinning as slow as I wanted it to, and stopping when I tried to slow it down. So I switched to trying to make a rack and pinion instead.

I went through several prototypes before settling on this, mainly because I spent most of the time figuring out how the automino kit works and looking up various rack and pinion setups online.  Several problems I had was getting the gear to rotate along the rack without slipping, and getting the gear on the rack at just the right height. Lots of tinkering was involved to get it to run by itself without me holding onto any of the parts.

The cat was the result of me needing a weight to hold the servo for the rack and pinion in place, and shaping it from some clay I had. I thought it was only natural for it to be looking at a bird.

Here’s the Fritzing diagram:

And the code:

#include 
Servo servo1, servo2;  // servo control object
int button = 2;
int period = 500;

void setup()
{
  servo1.attach(9);
  servo2.attach(10);
  Serial.begin(9600);
} 

void loop() {
  if(digitalRead(button) == LOW) {
      servo1.attach(9);
  servo2.attach(10);
    for (int angle = 0; angle  0; angle -= 1) {
      servo1.write(angle);
      delay (10); 
    }
    servo2.write(0);
    delay(500);
  }
  else {
    servo1.detach();
    servo2.detach();
  }
}

Post a comment