ICM & PCOM Synthesis / Week 5

dsc_0782v2

For this Synthesis workshop, I got my first introduction to the possibilities of what PCOM and ICM can do when they listen to each other. It was nice to be with the entire class in this hackathon-like vibe and to see what cool things would come out of this synthesis over pizza.

The design challenge was to create a Physical Variable. My partner, Roi Lev and I started off with connecting the serial communication and using a potentiometer to dim a red ellipse that was drawn in the p5.js sketch below.

We then took four colored buttons (red, green, blue and yellow) and attached them to the breadboard. Roi then programmed the buttons in p5.js to draw in the color that is pressed. For instance, to color in red, you need to hold down the red button while using your mouse to draw on the p5.js screen.

 

img_2172closeup of the circuit and breadboard

 

img_2163user testing

 


//p5.js CODE FOR RGBY DRAWING TOOL
var serial; // variable to hold an instance of the serialport library
var sensorValue = 0;  // ellipse position
 

function setup() {
  createCanvas(600, 400);
  serial = new p5.SerialPort();  
  // make a new instance of serialport library
  serial.on('list', printList);  
  // callback function for serialport list event
  serial.on('data', serialEvent);  
  // callback for new data coming in
    serial.list(); // list the serial ports
    serial.open("/dev/cu.usbmodem1421"); // open a port
    background(255);
}

function draw() {
  //background(255);
  noStroke();
  //fill(0);
  //text(sensorValue, 20, 20);
  //fill();
    if (sensorValue > 1 && sensorValue < 500){
        fill(255,255,0,120); 
    }else if (sensorValue > 500 && sensorValue < 900){
        fill(0,102,255);
    }else if (sensorValue > 900 && sensorValue < 1010){
        fill(0,204,0);
    }else if (sensorValue > 1010){
        fill(255,51,0);
    }//else{
        //fill(255);
    //}
    ellipse(mouseX, mouseY, 30, 30);
}

 function mousePressed(){
   background(255);
 }

// get the list of ports:
function printList(portList) {
 for (var i = 0; i < portList.length; i++) {
    // Display the list the console:
     println(i + " " + portList[i]);
 }
}

function serialEvent() {
    var inString = serial.readLine();
    if (inString.length > 0) {
      inString = inString.trim();
        //sensorValue = Number(inString/4);
        sensorValue = Number(inString);

    println(sensorValue);
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *