iPhone for Tantalus
Posted on October 3rd, 2008 in art, interaction design, technology |
The topic in last week’s pcomp class was analog output. Doing things like controlling motors or dimming LEDs requires a varying voltage. But, since you can’t actually generate a changing voltage directly from digital microcontrollers like the Arduino, it’s necessary to use “fake” an analog voltage. As Tom Igoe notes in his page on analog output, this is accomplished by producing a series of voltage pulses at regular intervals, and varying the width of the pulses. This is called pulse width modulation (PWM) (Note that this is only possible on analog pins labeled ‘PWM’ on the Arduino Diecimilla). The resulting average voltage is sometimes called a pseudo-analog voltage.
I was inspired with an idea for my project while thinking about how we are culturally obsessed with the newness of technology, and how that novelty is in many ways always just beyond our reach. As soon as we acquire the newest device or learn how to use the latest platform or language, something comes along to replace or improve upon it. I tried to literalize that condition with this little installation I set up in the workshop:
How everything works may not be completely clear from the video, but the basic concept is as follows. I’m using two force sensitive resistors on the floor (beneath the left and right foot silhouettes) to control the position of a servo motor. Attached to the servo motor is a wooden rod, to which a foam core model of an iPhone is tied. In its default state, the motor and rod point upwards at an angle of almost 90 degrees, thus holding the iPhone out of the reach of passersby. If the viewer ‘joins the queue’ by standing on the foot outlines, the pressure applied to the FSRs causes the motor to rotate the rod forward. The iPhone drops down, but it is still just out of reach. As the participant leans forward to grab the iPhone, they take pressure off the FSRs (which are located under the heels), causing the motor to rotate back, yanking the iPhone away. If they rock back on their heels, the motor rotates forward again. Over time, if they are tall enough and have long enough arms, some participants might be able to figure out the necessary pressure to bring the iPhone within their grasp, but overall I felt that the interaction and mechanics of this project were very successful.
I was also pleased with my ability to fabricate the simple but necessary components for this piece. Balsa wood and the band saw are my new best friends. As far as the code for this project (see below), it was fairly simple. Figuring out the range of motion for the motor (minPulse and maxPulse vars in the code below) required a little trial and error, but most of the effort in this project was the fabrication.
int servoPin = 2; // Control pin for servo motor
int minPulse = 1700; // Minimum servo position
int maxPulse = 2420; // Maximum servo position
int pulse = 0; // Amt to pulse the servolong lastPulse = 0; // Time in milliseconds of the last pulse
int refreshTime = 20; // Time needed in between pulsesint analogValue = 0; // Value returned from the analogue sensor
int analogPin0 = 0; // Analog pins receiving from FSR
int analogPin1 = 1;void setup() {
pinMode(servoPin, OUTPUT);
pulse = minPulse;
Serial.begin(9600);
}void loop() {
analogValue = (analogRead(analogPin0)/2)+(analogRead(analogPin1)/2); // Read the analog pins
pulse = map(analogValue, 0, 1023, minPulse, maxPulse); // Convert analog value to range b/w min and max pulse
Serial.println(pulse);// Pulse servo again if refresh time (20 ms) has passed
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulse); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // Save the time of the last pulse
}
}