bio photo

Email

##Synthesis

For our synthesis project Emannuel and I were paired up (and later joined by Eve) because her partner wasn’t there. We worked on using a potentiometer to serially communicate with p5 and load Images as the knob is turned.

Out initial idea was to use a simple pot and images of puppies downloaded from the internet. But Eve has a small wooden tree and 28 images of it.

Programming that was still going to be difficult since we were new to the concept.

I worked on the circuit, Emanuel drilled a hole in the tree to fit a pot, Eve loaded the images on p5.

For programming the Arduino and p5 sketch, we worked on the basics, but ran into some problems with the Serial library (as it was newly launched). I looked for Sam and cajoled him to come down in what was a very busy day for him. He fixed that.

Then we got the p5 to work! Code below:

//Creating animations

//animations like p5 images should be stored in variables
//in order to be displayed during the draw cycle
var tree;
var rotation;
var serial;

//it's advisable (but not necessary) to load the images in the preload function
//of your sketch otherwise they may appear with a little delay
function preload() {

//create an animation from a sequence of numbered images
//pass the first and the last file name and it will try to find the ones in between
//asterisk = loadAnimation("assets/asterisk.png", "assets/triangle.png", "assets/square.png", "assets/cloud.png", "assets/star.png", "assets/mess.png", "assets/monster.png");
tree = loadAnimation("assets/Tree_00000.png", "assets/Tree_00028.png");

  
}

function setup() {
  createCanvas(1000,1000,windowWidth,windowHeight);
    //animation(tree, width/2, height/2);
    
    serial = new p5.SerialPort();
    serial.open("/dev/cu.usbmodem1411");
    serial.onData(gotData);

}
function gotData() {
  // Read the data as text (a string)!
  var data = serial.readLine();
  // Check to make sure something really came in
  if (data.length > 0); {
    rotation=data;
    // Look at the data
    // Do something with it, like to another variable?
    console.log(data);
    
    
    
    //specify the animation instance and its x,y position
  //animation() will update the animation frame as well
    image(tree.getImageAt(rotation),0,0,windowWidth,windowHeight);
  }
}

function draw() {
  //background(255,255,255);  
  // print(rotation)
  
  
  
  
//  animation(asterisk, 500, 150);
}

//ARDUINO SKETCH CODE

// Analog Sensor

int inPin = A0;   // Sensor connected to analog pin 0
int val = 0;     // variable to store the read value
int frame;

void setup() {
  Serial.begin(9600);
  pinMode(inPin, INPUT);
}

void loop() {
  val = analogRead(inPin);   // read the input pin
  frame=map(val,0,1023,0,28);
  Serial.println(frame);
  delay(33); // 30 frames per second
}

###Video

It was a crowd favorite with special appreciation from DanO, LaurenMcCarthy, DanShiffman & Shawn Avery.

###Conclusion:

This project would’ve been nothing if three active minds hadn’t played their cards right and hoped for the best. We all complimented eachothers skills and programmed a great experience for the user.