« Resistor Plate Beatbox Prototype | Main | Ephemeral Graffiti »

Solenoid Heart Rhythm Bear

Pictures and Code Examples on Extended Entry

DSCF0776.JPG DSCF0779.JPG
Here are the guts from the prototype of the rhythm bear. The noises emanating from the bear come from the internal stops of two rotational solenoids. The solenoids are fired in a repeated lopsided pattern meant to simulate a mechanical heartbeat. The periodicity of this beat increases when the bear's abdomen is depressed, thus simulating the racing of the heart brought about by physical contact. In order to accommodate the solenoids from the low-voltage arduino board I had to build a driver board to step up the 5 volt/30mA digital pin output of the arduino board to 9 volt/300mA. This board uses TIP102 transistors to step up the current and 1N4004 diodes for isolation of the inductive spike produced when the solenoid is turned off. (Without this, amplified current could feedback into the arduino and burn it up). The driver board accommodates up to four solenoids at a time, but here only two are used. The whole package is meant to fit inside the abdominal cavity of a stuffed animal so the solenoids, driver-board and arduino are all mounted to a slim wooden substrate.
Development of the control software was initially done in Max/MSP using a Pure Data <-> Arduino protocol. I have since implemented the same functionality with arduino code. Video forthcoming.

Solenoid Driver Circuit: http://www.arduino.cc/playground/uploads/Learning/solenoid_driver.pdf
Solenoid Tutorial: http://www.arduino.cc/playground/Learning/SolenoidTutorial

/* Solenoid driven heart rhythm bear~~~~~~
* For use with the Arduino board connected to a 4x solenoid driver board
* Fires two solenoids in sequence with variable inter-onset time determined
* by the state of a simple switch.
*/

int outPin1 = 13; // Solenoid #1 output pin
int outPin2 = 12; // Solenoid #2 output pin
int inPin1 = 8; // Switch input pin
int inVal = 0; // Variable for holding input pin STATE
double pause = 200; // Initial reference delay between firings

void setup()
{
pinMode(outPin1, OUTPUT); // sets digital pin 13 as output
pinMode(outPin2, OUTPUT); // sets digital pin 12 as output
pinMode(inPin1, INPUT); // sets digital pin 8 as input
}

void loop() // loop forever
{
inVal = digitalRead(inPin1); // get the state of the simple switch
if(inVal == LOW){ // if LOW (< 3 Volts)
pause = pause*.66; // set the reference delay to 2/3 its previous value
if(pause < 200){ // now if reference delay is below 200 ms
pause = 200; // set to 200 ms
}
}

if(inVal == HIGH){ // if HIGH (> 3 Volts)
pause = pause * 1.25; // set reference delay to 125% its previous value
if(pause > 833){ // now if reference delay is above 833 ms
pause = 833; // set to 833 ms
}
}

digitalWrite(outPin1, HIGH); // turn on solenoid one "click"
delay(20); // wait a tick
digitalWrite(outPin1, LOW); // turn off solenoid one
delay(pause); // wait reference delay
digitalWrite(outPin2, HIGH); // turn on solenoid two "click"
delay(20); // wait a snap
digitalWrite(outPin2, LOW); // turn off solenoid two
delay(pause * 1.5); // wait 2:3 ratio to reference delay
}//end of loop