Description:
In this lab exercise, we used a servo motor to explore rotational and linear motions. First, we used the Arduino environment to control the rate of rotation, and then we employed a potentiometer for the same purpose.
For the homework assignment, I created a (rather coarse) "crawling hand", inspired on the upcoming Halloween festivities. I used pieces of plywood to create a mechanical lever and I attached them to the servo motor, which I then taped unto its own box.
I used a very simple code to automate the movement of the servo motor from the 10º to the 150º degree position, and vice-versa, such that the motor would be continuously rocking back and forth. I slightly modified one of the templates in the examples sketchbook in the Arduino application for this purpose.
A demo of the operating "crawling hand" can be seen here:
https://drive.google.com/file/d/0ByMuJqORzfcSQjM4M3F5N0NsZzA/edit?usp=sh...
Code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
myservo.write(10); // sets the servo position according to the scaled value
delay(1000); // waits for the servo to get there
myservo.write(150); // sets the servo position according to the scaled value
delay(1000); // waits for the servo to get there
}
- Login to post comments