PCOMP 4 / IFAB 4 / ICM 4: ENCLOSURES, ARDUINO IO, P5 SERIAL

I had the plan to create a sound / visual controller for Arduino tone and P5 that uses fruits as an input element. The controller would sit on a steel basket that houses the fruits, it would feature several knobs and faders and would be connected to P5 via the serial port. 

IMG_1827.JPG

To accompany the cleanliness of the steel I wanted to combine plywood and acrylic for the topin two layers: plywood cutouts of hands sitting on top of white translucent acrylic. The goal was to avoid any glue. 

After going through the Arduino Tone lab I started writing the code and ended up using a different library for sound that would give me additional volume and wave-type control in combination with the tone library. I tested as well the P5 serial library with a potentiometer after following the steps in the serial lab and running a node server on my local machine. 

#include "volume2.h"
Volume vol;
const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

int inputPin = A0;
int inputPin1 = A4;

int analogPin= 3;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 10000;
float R2= 0;
float buffer= 0;

//int val1;
int encoder0PinA = 2;
int encoder0PinB = 4;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;

void setup() {
  pinMode (encoder0PinA, INPUT);
  pinMode (encoder0PinB, INPUT);
  Serial.begin(9600);
    for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}


void loop() {
    int n = digitalRead(encoder0PinA);
    if ((encoder0PinALast == LOW) && (n == HIGH)) {
    if (digitalRead(encoder0PinB) == LOW) {
      encoder0Pos--;
    } else {
      encoder0Pos++;
    }
    //Serial.println (encoder0Pos);
    //Serial.print ("/");
  }
  encoder0PinALast = n;

  
    raw= analogRead(analogPin);
  if(raw) 
  {
  buffer= raw * Vin;
  Vout= (buffer)/1024.0;
  buffer= (Vin/Vout) -1;
  R2= R1 * buffer;
  
  Serial.print("Vout: ");
  Serial.println(Vout);
  Serial.print("R2: ");
  Serial.println(R2);
  //
  }
  //int Sound = analogRead(analogPot);
  //float frequency = map(Sound, 0, 40000, 100, 1000);
  //tone(8, frequency, 10);
  //Serial.println(frequency);

  
    // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(inputPin);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  //Serial.println(average);
  delay(1);        // delay in between reads for stability
  int freq = analogRead(A0);
  int volume = map(analogRead(A1), 0, 1023, 0, 255);
  
  //Serial.println(freq);
  Serial.println(encoder0Pos);

  
  
  vol.tone(encoder0Pos*10, SQUARE, volume); // 100% Volume
  vol.delay(analogRead(A3));
  vol.tone(freq, SQUARE, volume); // 75% Volume
  vol.delay(analogRead(A3));
  vol.tone(freq, SQUARE, volume); // 50% Volume
  vol.delay(analogRead(A3));
  vol.tone(freq, SQUARE, volume); // 25% Volume
  vol.delay(analogRead(A3));
  vol.tone(freq, SQUARE, volume); // 12.5% Volume
  vol.delay(analogRead(A3));
}
IMG_1760.JPG

Having sorted out the basic functionality of the code, thinking about the parts I would need for the controller and sourcing all parts, I constructed the building files for the laser-cutter in Illustrator. This took a fair amount of time as I had to measure all parts for a perfect fit. I used the analog caliber for most of the measurements. 

IMG_1771.JPG
IMG_1768.JPG

Especially parts like the fader needed extra engineering / construction before laser-cutting.

Screen Shot 2017-09-30 at 10.48.34 PM.png

I used the tracing of images technique to get the positions of the controller elements ergonomically right. I used the sandwich technique of etching and cutting in combination with the two different top layers to get a seamless fit. I traced my hands for the shapes around the controller elements. 

Screen Shot 2017-10-04 at 12.46.19 AM.png

The etching layer would create a rim around the cutouts for washers and speakers to fit them underneath the top-plate.

Screen Shot 2017-10-04 at 12.51.45 AM.png

After cutting both layers the etching took too long - the laser was not strong enough to etch the required amount of material (around 3mm) out of the acrylic. With the help of one of my fellow students, Itay, I managed to used a drill and a dremel to deepen the rims around both speakers and each of the cutouts of the potentiometers. 

IMG_1789.JPG
IMG_1791.JPG
IMG_1802.JPG
IMG_1806.JPG

I used knobs from the junk shelf as they fit the white/light brown colors of wood and acrylic. 

After that I started screwing in all electronic parts - thanks to the time I spent measuring the controller elements they fit perfectly. I was relieved! 

IMG_1803.JPG

I still had to drill the screw holes for the standoffs for Arduino and fader. 

IMG_1811.JPG
IMG_1812.JPG

The last part of the hardware building was the wiring. I used a perf-board to organize the multiple wires of all the elements and soldered each of them. It took me a full afternoon, but thanks to a soldering workshop earlier in my PComp class I could avoid the biggest mistakes. Still - there is plenty of room to learn for me in this particular technique.

I ended up not attaching wires to the fruits in the basket as I wanted to keep the controller as open as possible - it should be usable for sound creation and control of visuals alike.

IMG_1818.JPG

I wanted to use magnets to keep the top secure on the steel basket but didn't attach them to the acrylic yet as I wanted to test first whether I could screw them into the acrylic as well - something to be done later this week. The same goes for the top plate consisting of two layers. They are secured and stick together because of the knobs, I still need to figure out how I can attach it safely without drilling or glue. So far all elements are functional and can be assigned different functions. I used it mainly for sound production.

So far I have not tested the sound libraries a lot, so most of the sounds are very experimental - but fun! 

I have tested the P5 serial communication with a potentiometer - so far it is a very satisfying feeling to have a physical control element instead of a trackpad.

I would as well like to put lights underneath each hand/  controller element to communicate with plants: The plant listens to the music, a sensor measures the surface conductivity that is mapped to the controller elements, they light up according to this conductivity and I can react to this interaction with the plant. Sounds a bit lofty - but worth exploring!

So far no fruits in the basket below but plenty ideas on how to continue with my first controller.

IMG_1823.JPG

 Parts used:

  • 3mm plywood
  • 6mm white translucent acrylic
  • steel basket
  • magnets
  • Arduino Uno
  • crossfader / slider
  • 2 x potentiometer
  • rotary encoder
  • 2 x 8 Ohm speaker
  • USB cable

Tools used:

  • lasercutter
  • drill-press with hole-saw drillbit
  • Dremel
  • soldering iron