Joe Biden's Fist Pump

Posted by lizzy

Anonymous's picture

Description:

This code was inspired by this GIF:
 http://valcakes.tumblr.com/post/2944869622/thedailywhat-animated-gif-of-the-day-took-you
 
  I wanted to be able to control animated GIFs by hand.
 
  Both FSR and photo cell controls the animation.
  I wrote condition statements for each, though the condition statements for the photocell is commented out.
 
  For the FSR, the lighter the tap, the faster the animation.
  Conversely, the harder you squeeze, the longer the last last image stays up.
 
  For the Photocell, the less light, the image stays on the first frame (no fist).
  The more light, the image moves to second frame (fist).
 
  I also made the Processing screen read the value of the LED

For the mechanical portion of the instrument, I used a hammer to hit the FSR. The FSR was placed under layers for felt. I was afraid of damaging the FSR.  I used a hammer because it reminded me of the gavel that is used during the State of the Union address.

Components

Breadboard

Arduino Microcontroller

RGB LEDs

Resistors

1 FSR

1 photocell

Hammer

 

Code

/*
 * Vice President Joe Biden!!!1!
 * ----------------------
 * This code was inspired by this GIF:
 * http://valcakes.tumblr.com/post/2944869622/thedailywhat-animated-gif-of-...
 *
 * I wanted to be able to control animated GIFs by hand.
 *
 * Both FSR and photo cell controls the animation.
 * I wrote condition statements for each.
 *
 * For the FSR, the lighter the tap, the faster the animation.
 * Conversely, the harder you squeeze, the longer the last last image stays up.
 *
 * For the Photocell, the less light, the image stays on the first frame (no fist).
 * The more light, the image moves to second frame (fist).
 *
 *I also made the Processing screen read the value of the LED.
 *
 * This code was modified. Original code was the Arduino Balls code which was
 * created 25 October 2006
 * copyleft 2006 Tod E. Kurt <tod@todbot.com
 * http://todbot.com/
 *
 */
import processing.serial.*;

PImage b1;
PImage b8;


// Change this to the portname your Arduino board
String portname = "/dev/tty.usbmodem621"; // or "COM5"
Serial port;
String buf="";
int cr = 13;  // ASCII return   == 13
int lf = 10;  // ASCII linefeed == 10
void setup() {
  b1=loadImage("biden_tumbler1.gif");// set up biden images
  b8=loadImage("biden_tumbler8.gif");

  size(185,198);
//  frameRate(1);
  smooth();
  background(40,40,40);
  noStroke();
  port = new Serial(this, portname, 9600);
 
}
void draw() {
 // nothing happens here
 
}

// called whenever serial data arrives
void serialEvent(Serial p) {
  int c = port.read();
  if (c != lf && c != cr) {
    buf += char(c);
  }
  if (c == lf) {
    int val = int(buf);
    if (val > 255){ // presents brightness of LED, so 255 is max brightness.
      val = 255;
    }
   println("Led val="+val);
//Condition for FSR
   if(val == 0){
      image(b1,0,0);
    }
    
    else if (val > 1){// i noticed the FSR value went into the 800s, so I divided 800 by number of images. And incremented 'val' by that value (57)
      image(b8,0,0);
    }
      

//Condition for Photo cell
//    if(val == 0 || val < 100 ){
//      image(b1,0,0);
//    }

     
     buf = "";
   }
 
 
}

 

Movies

Hammering

Computer output

;

Screen shot 2011-02-19 at 12.46.39 PM.png
Screen shot 2011-02-19 at 12.46.32 PM.png
photocell.jpg
nohammer.jpg
hammer.jpg
fsr.jpg
0
Your rating: None