Electric Chair Bear

Liesje, Tim and I finished our midterm project for Physical Computing tonight.  Our original concept was the Voodoo Bear, but after managing to break a couple sensors and a vibration motor in the building process, we decided go with a slightly different concept.

Here it is in action:

The setup allows us to inflict Arduino-based violence against the bear, representing our frustration with the bear and the difficulties of building something from the outside in rather than from the inside out.  It can also be read as a demented commentary on the death penalty (which I’m against) or as a kind of shock therapy that de-incentivizes eating candy – good for people trying to control their diet.  Eat chocolate and the bear dies.

Tim talks more about the process on his blog:

The Electric Chair Bear came to fruition this evening as Liesje, Lee-Sean, and I had a revelation yesterday evening about making the voodoo bear concept we had be a voodoo/electric chair bear.  We were having some serious problems making the servo motors do everything we wanted by building the bear’s components, sensors, and motors from the inside out.  We also destroyed about 3 different things including a flex and stretch sensor and a mini vibrating motor.  This was all due to the structure of the bear and the complexity of inserting motors and sensors into the bear.  We did get the bear to do some cool things with the eye connected to a motor as well as putting an LED into the bear’s eye, so that when you shake an accelerometer the bear’s eye moves and the LED turns on and off.  The accelerometer also turns on another servo motor to give slight motion to an arm.    We constructed a chair that looks like previous teddy bears could have been put to death in, and connected tin foil as a metal helmet, sharp teeth, leg shackles, and a lighting bolt across the chest so that the bear sits in the chair, and when the accelerometer is activated, the bear reacts accordingly and looks like he is being electrocuted.  The lightning bolt really makes it “The Electric Chair Bear,” the anti-care bear.  The acceleromoter is attached to a candy bar as incentive so that when a famished passerby sees it, he will pick it up and activate the acceleromoter.  We also wrote a Processing program so that when the accelerometer is activated, the Electric Chair Bear shakes in the processing sketch that has an image of the bear.  The background also freaks out between blue and red to give an added effect of electric proportions.  We also wrote a function so that when the mouse rolls over the distinctly weird eye in question, the LED turns on.  We are very happy with our Electric Chair Bear, and feel as though this idea is even creepier and better for the Haunted House than the original idea.

Here is the Arduino code:

int servoPin = 11;     // Control pin for servo motor – Eye
int servoPin2 = 12;    // Hand
int minPulse = 500;   // Minimum servo position
int maxPulse = 2500;  // Maximum servo position
int pulse = 0;        // Amount to pulse the servo
int ledPin = 4;
int pulseWidth;

long lastPulse = 0;    // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses

int analogValue = 0;  // the value returned from the analog sensor
int analogPin = 0;    // the analog pin that the sensor’s on

int buttonSwitch = 2;      // switch
int buzzerPin = 8;         //buzzer
int motor = 0;
int sensorValue = 0;     // reading from the sensor
int buttonValue;
int ledOn = 0;
int accelerometer = 0;
int accelValuePrev;
int accelValue;

void setup() {
// configure the serial connection:
pinMode(ledPin, OUTPUT);
pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
pinMode(servoPin2, OUTPUT);

Serial.begin(9600);
// configure the digital input:
pinMode(buttonSwitch, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(accelerometer, INPUT);
digitalWrite(buzzerPin, HIGH);

}

void loop() {
if (Serial.available() > 0) {
ledOn = Serial.read();
if(ledOn == 1){
digitalWrite(ledPin, HIGH);
}
else if (ledOn == 0){
digitalWrite(ledPin, LOW);
}
}
accelValue = analogRead(accelerometer);
sensorValue = digitalRead(buttonSwitch);
buttonValue = sensorValue;

if (abs(accelValue-accelValuePrev) >15){
Serial.print(1, BYTE);
turnServo(180);
delay(20);
turnServo(5);

digitalWrite(buzzerPin, HIGH);
digitalWrite(ledPin, HIGH);

}
else  {
Serial.print(0, BYTE);
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
}
accelValuePrev = accelValue;
}

void turnServo(int angle) {
int i;
// this loop is done in order to turn the servo motor to the wanted angle
for( i=1;i<angle ;i=i+10 ){

// calculates the amount to pulse to the servo (this servo can turn maximum 180 degrees)
pulse = (i*2500)/180;
// add the minimum amount for the pulse, and the relative position of the given angle
// compared to the maximum angle
pulse += 500+((2000/180)*i);
// pulse the servo motor
pulsout( servoPin, pulse);
pulsout( servoPin2, pulse);
}
}

void pulsout( int servoPin, int pulse) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulse); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
delay(20); // 20 millisecond delay is needed between pulses
}

Here is the Processing code

import processing.serial.*;
Serial myPort;  // The serial port

float  buttonSwitch, accelerometer, accelerometerPrev;
float accelSensitivity = 5;
//the values below are calibrated for use in the processing program

int accel = 0;
PImage[] bear = new PImage [8];
int frame = 0;  //frame counter for vibration

void setup()
{
println(Serial.list());
myPort = new Serial (this, Serial.list()[0], 9600);
size(600,800);
noStroke();
bear[0] = loadImage(“voodoo-bear_blue_small.jpg”);
bear[1] = loadImage(“voodoo-bear_red_small.jpg”);
bear[2] = loadImage(“voodoo-left-red.jpg”);
bear[3] = loadImage(“voodoo-left-blue.jpg”);
bear[4] = loadImage(“voodoo-bear_blue_small.jpg”);
bear[5] = loadImage(“voodoo-bear_red_small.jpg”);
bear[6] = loadImage(“voodoo-right-blue.jpg”);
bear[7] = loadImage(“voodoo-right-red.jpg”);
image(bear[0], 0,0);
}

void draw()
{
frame = (frame+1)%8;
//turn background red if mouse gets close to the zombie eye
if(dist(mouseX, mouseY, 240, 190) < 56)
{
fill(255,0,0,160); //transparent red
myPort.write(1); //send one to Arduino to turn on eye
image(bear[1], 0,0);
//ellipse(240,190,55,55);  //Finding the eye
}
else {
image(bear[0], 0,0);
// myPort.write(0);
}
if(accel==1){
shakeBear();
}
}

void serialEvent (Serial myPort) {
// get the byte:
int inByte = myPort.read();
// print it:
println(inByte);
accel = inByte;
}

void shakeBear(){
image (bear[frame], 0,0);
}

More photos and videos on Flickr.

Published by

leesean

Foossa Facts