Homage to Man Ray
Friday, October 12th, 2007This was one of my first efforts to connect the Arduino prototyping board to a servo motor. This implementation was based on Tom Igoe’s hints on servo motors. When the unit is powered-up, the servo motor rotates back and forth through almost 180 degrees, similar to Man Ray’s surrealist sculpture, Object to Be Destroyed (1923). I snipped out the eye from a photo of the original and used that for the extra dollop of authenticity! Yes, that’s BluTack holding a coffee stir stick onto the servo motor!
The code for this project is here:
// A simple program to rotate a servo back and forth through
// its range of motion.
// by Brock Craft.
//
// Thanks to Tom Igoe for hints!
#include <Servo.h>
int v=0;
Servo servo1;
void setup() {
pinMode(1,OUTPUT);
servo1.attach(9);
Serial.begin(19200);
}
void loop() {
v=v+1;
Serial.println(v);
servo1.write(v);
Servo::refresh();
delay(50);
if (v>179){
for (int i=180;i>0;i=i-1){
servo1.write(i);
Serial.println(i);
Servo::refresh();
delay(50);
}
v=0;
}
}