Prototype 3 / Final Iteration

This is it. This is the culmination of all of our work so far, in the final prototype, which will end up becoming the final product. So far there have only been iPhone quality pictures but now behold, toneglow.
EDITED_IMG_9922EDITED_IMG_9972EDITED_IMG_9981EDITED_IMG_9978
The system has not gone through any major changes since its first iteration, and I think this is largely because we had a strong idea of what we wanted to create from the beginning. The major differences are that we didn’t use distance sensors due to the issues discussed in the first prototype blog post, and we only ended up making 5 control units. This was partially due to time constraints and the ambiguity in the sound which each one controlled. Ultimately though, with the bar we had and the scale we were creating, 6 balls or more would have been too cluttered and probably would have tangled with each other or something like that. There have been some setbacks along the way, but this was to be expected. And ultimately we are very happy with the result we were left with.
Fritzing Diagram:
This is essentially a condensed version of how the system works. In the actual one all the cables are extended and routed with ethernet cables, but i thought this would take too much unnecessary space.
Prototype 3 : final_bb
Code:
You will notice that the code for this prototype has gone through some substantial changes. Most noteably, the smoothing. This is because we found that as we added more inputs, the analogue values became more and more rough, throwing outliers all over the place. The smoothing helps with this, it means the LEDs don’t flash all over the place and do things they aren’t meant to do. You may notice that we have deliberately not outputted the smoothed data to Max/MSP, this is because we quite liked the random blips of data being sonified, and they give more sonic dynamics, especially when the system is in its resting state.
//This is the code for Prototype 3 with 5 balls with LEDs
//It is also the final code

const int one = A0;
const int two = A1; 
const int three = A2;
const int four = A3;
const int five = A4;
const int six = A5;
const int seven = A6;
const int eight = A7; 
const int nine = A8;
const int ten = A9;

int ledOne = 2;
int ledTwo = 3;

int ledThree= 4;
int ledFour = 5;

int ledFive = 6;
int ledSix = 7;

int ledSeven = 8;
int ledEight = 9;

int ledNine = 10;
int ledTen = 11;

int brightness;
int bbrightness;

// brightness for rel LEDs
int brightnessOne;
int brightnessTwo;
int brightnessThree;
int brightnessFour;
int brightnessFive;

//For the pulsating green light
int pulseBrightness;
float pulseRate;

//smoothing modified from https://www.arduino.cc/en/Tutorial/Smoothing

/////////// smoothing A0 /////////// 
const int numReadingsA0 = 10;
int readingsA0[numReadingsA0];
int readIndexA0 = 0;
int totalA0 = 0;
int averageA0 = 0;
//////////////////////////////////////

/////////// smoothing A1 /////////// 
const int numReadingsA1 = 10;
int readingsA1[numReadingsA1];
int readIndexA1 = 0;
int totalA1 = 0;
int averageA1 = 0;
//////////////////////////////////////

/////////// smoothing A2 /////////// 
const int numReadingsA2 = 10;
int readingsA2[numReadingsA2];
int readIndexA2 = 0;
int totalA2 = 0;
int averageA2 = 0;
//////////////////////////////////////

/////////// smoothing A3 /////////// 
const int numReadingsA3 = 10;
int readingsA3[numReadingsA3];
int readIndexA3 = 0;
int totalA3 = 0;
int averageA3 = 0;
//////////////////////////////////////

/////////// smoothing A4 /////////// 
const int numReadingsA4 = 10;
int readingsA4[numReadingsA4];
int readIndexA4 = 0;
int totalA4 = 0;
int averageA4 = 0;
//////////////////////////////////////

/////////// smoothing A5 /////////// 
const int numReadingsA5 = 10;
int readingsA5[numReadingsA5];
int readIndexA5 = 0;
int totalA5 = 0;
int averageA5 = 0;
//////////////////////////////////////

/////////// smoothing A6 /////////// 
const int numReadingsA6 = 10;
int readingsA6[numReadingsA6];
int readIndexA6 = 0;
int totalA6 = 0;
int averageA6 = 0;
//////////////////////////////////////

/////////// smoothing A7 /////////// 
const int numReadingsA7 = 10;
int readingsA7[numReadingsA7];
int readIndexA7 = 0;
int totalA7 = 0;
int averageA7 = 0;
//////////////////////////////////////

/////////// smoothing A8 /////////// 
const int numReadingsA8 = 10;
int readingsA8[numReadingsA8];
int readIndexA8 = 0;
int totalA8 = 0;
int averageA8 = 0;
//////////////////////////////////////

/////////// smoothing A9 /////////// 
const int numReadingsA9 = 10;
int readingsA9[numReadingsA9];
int readIndexA9 = 0;
int totalA9 = 0;
int averageA9 = 0;
//////////////////////////////////////
 
 

void setup()
{
 Serial.begin(9600);
 
 // initialize all the readings to 0:
 /////////// smoothing A0 /////////// 
 for (int thisReadingA0 = 0; thisReadingA0 < numReadingsA0; thisReadingA0++) {readingsA0[thisReadingA0] = 0;}
 
 /////////// smoothing A1 /////////// 
 for (int thisReadingA1 = 0; thisReadingA1 < numReadingsA1; thisReadingA1++) {readingsA1[thisReadingA1] = 0;}
 
 /////////// smoothing A2 /////////// 
 for (int thisReadingA2 = 0; thisReadingA2 < numReadingsA2; thisReadingA2++) {readingsA2[thisReadingA2] = 0;}
 
 /////////// smoothing A3 /////////// 
 for (int thisReadingA3 = 0; thisReadingA3 < numReadingsA3; thisReadingA3++) {readingsA3[thisReadingA3] = 0;}
 
 /////////// smoothing A4 /////////// 
 for (int thisReadingA4 = 0; thisReadingA4 < numReadingsA4; thisReadingA4++) {readingsA4[thisReadingA4] = 0;}
 
 /////////// smoothing A5 /////////// 
 for (int thisReadingA5 = 0; thisReadingA5 < numReadingsA5; thisReadingA5++) {readingsA5[thisReadingA5] = 0;}
 
 /////////// smoothing A6 /////////// 
 for (int thisReadingA6 = 0; thisReadingA6 < numReadingsA6; thisReadingA6++) {readingsA6[thisReadingA6] = 0;}
 
 /////////// smoothing A7 /////////// 
 for (int thisReadingA7 = 0; thisReadingA7 < numReadingsA7; thisReadingA7++) {readingsA7[thisReadingA7] = 0;}
 
 /////////// smoothing A8 /////////// 
 for (int thisReadingA8 = 0; thisReadingA8 < numReadingsA8; thisReadingA8++) {readingsA8[thisReadingA8] = 0;}
 
 /////////// smoothing A9 /////////// 
 for (int thisReadingA9 = 0; thisReadingA9 < numReadingsA9; thisReadingA9++) {readingsA9[thisReadingA9] = 0;}
 
 
 pinMode(ledOne, OUTPUT);
 pinMode(ledTwo, OUTPUT);
 pinMode(ledThree, OUTPUT);
 pinMode(ledFour, OUTPUT);
 pinMode(ledFive, OUTPUT);
 pinMode(ledSix, OUTPUT);
 pinMode(ledSeven, OUTPUT);
 pinMode(ledEight, OUTPUT);
 pinMode(ledNine, OUTPUT);
 pinMode(ledTen, OUTPUT);

}

void loop()
{
 
 
 //for the pulsing of the Green LEDs
 pulseRate += 0.1;
 pulseBrightness = 45+(210*(((cos(pulseRate))+1)/2));
 
 /////////// smoothing A0 /////////// 
 totalA0 = totalA0 - readingsA0[readIndexA0];
 readingsA0[readIndexA0] = analogRead(one);
 totalA0 = totalA0 + readingsA0[readIndexA0];
 readIndexA0 = readIndexA0 + 1;
 if (readIndexA0 >= numReadingsA0) {
 readIndexA0 = 0;
 }
 averageA0 = totalA0 / numReadingsA0;
 //////////////////////////////////////
 
 /////////// smoothing A1 /////////// 
 totalA1 = totalA1 - readingsA1[readIndexA1];
 readingsA1[readIndexA1] = analogRead(two);
 totalA1 = totalA1 + readingsA1[readIndexA1];
 readIndexA1 = readIndexA1 + 1;
 if (readIndexA1 >= numReadingsA1) {
 readIndexA1 = 0;
 }
 averageA1 = totalA1 / numReadingsA1;
 //////////////////////////////////////
 
 /////////// smoothing A2 /////////// 
 totalA2 = totalA2 - readingsA2[readIndexA2];
 readingsA2[readIndexA2] = analogRead(three);
 totalA2 = totalA2 + readingsA2[readIndexA2];
 readIndexA2 = readIndexA2 + 1;
 if (readIndexA2 >= numReadingsA2) {
 readIndexA2 = 0;
 }
 averageA2 = totalA2 / numReadingsA2;
 //////////////////////////////////////
 
 /////////// smoothing A3 /////////// 
 totalA3 = totalA3 - readingsA3[readIndexA3];
 readingsA3[readIndexA3] = analogRead(four);
 totalA3 = totalA3 + readingsA3[readIndexA3];
 readIndexA3 = readIndexA3 + 1;
 if (readIndexA3 >= numReadingsA3) {
 readIndexA3 = 0;
 }
 averageA3 = totalA3 / numReadingsA3;
 //////////////////////////////////////
 
 /////////// smoothing A4 /////////// 
 totalA4 = totalA4 - readingsA4[readIndexA4];
 readingsA4[readIndexA4] = analogRead(five);
 totalA4 = totalA4 + readingsA4[readIndexA4];
 readIndexA4 = readIndexA4 + 1;
 if (readIndexA4 >= numReadingsA4) {
 readIndexA4 = 0;
 }
 averageA4 = totalA4 / numReadingsA4;
 //////////////////////////////////////
 
 /////////// smoothing A5 /////////// 
 totalA5 = totalA5 - readingsA5[readIndexA5];
 readingsA5[readIndexA5] = analogRead(six);
 totalA5 = totalA5 + readingsA5[readIndexA5];
 readIndexA5 = readIndexA5 + 1;
 if (readIndexA5 >= numReadingsA5) {
 readIndexA5 = 0;
 }
 averageA5 = totalA5 / numReadingsA5;
 //////////////////////////////////////
 
 /////////// smoothing A6 /////////// 
 totalA6 = totalA6 - readingsA6[readIndexA6];
 readingsA6[readIndexA6] = analogRead(seven);
 totalA6 = totalA6 + readingsA6[readIndexA6];
 readIndexA6 = readIndexA6 + 1;
 if (readIndexA6 >= numReadingsA6) {
 readIndexA6 = 0;
 }
 averageA6 = totalA6 / numReadingsA6;
 //////////////////////////////////////
 
 /////////// smoothing A7 /////////// 
 totalA7 = totalA7 - readingsA7[readIndexA7];
 readingsA7[readIndexA7] = analogRead(eight);
 totalA7 = totalA7 + readingsA7[readIndexA7];
 readIndexA7 = readIndexA7 + 1;
 if (readIndexA7 >= numReadingsA7) {
 readIndexA7 = 0;
 }
 averageA7 = totalA7 / numReadingsA7;
 //////////////////////////////////////
 
 /////////// smoothing A8 /////////// 
 totalA8 = totalA8 - readingsA8[readIndexA8];
 readingsA8[readIndexA8] = analogRead(nine);
 totalA8 = totalA8 + readingsA8[readIndexA8];
 readIndexA8 = readIndexA8 + 1;
 if (readIndexA8 >= numReadingsA8) {
 readIndexA8 = 0;
 }
 averageA8 = totalA8 / numReadingsA8;
 //////////////////////////////////////
 
 /////////// smoothing A9 /////////// 
 totalA9 = totalA9 - readingsA9[readIndexA9];
 readingsA9[readIndexA9] = analogRead(ten);
 totalA9 = totalA9 + readingsA9[readIndexA9];
 readIndexA9 = readIndexA9 + 1;
 if (readIndexA9 >= numReadingsA9) {
 readIndexA9 = 0;
 }
 averageA9 = totalA9 / numReadingsA9;
 //////////////////////////////////////
 
 
 brightness = averageA0;
 bbrightness = averageA1;
 
 // mapping brighntnesses for red leds
 brightnessOne = map (averageA1, 480, 630, 0, 255);
 brightnessTwo = map (averageA3, 500, 800, 0, 255);
 brightnessThree = map (averageA5, 450, 800, 0, 255);
 brightnessFour = map (averageA7,550, 800, 0, 255);
 brightnessFive = map (averageA9, 550, 800, 0, 255);

 
 
 // limiting values so they don't wrap if they go beyond the map function
 if (brightnessOne > 244) {brightnessOne = 255;}
 if (brightnessOne < 1 ) {brightnessOne = 0 ;}
 if (brightnessTwo > 244) {brightnessTwo = 255;}
 if (brightnessTwo < 1 ) {brightnessTwo = 0 ;}
 if (brightnessThree > 244) {brightnessThree = 255;}
 if (brightnessThree < 1 ) {brightnessThree = 0 ;}
 if (brightnessFour > 244) {brightnessFour = 255;}
 if (brightnessFour < 1 ) {brightnessFour = 0 ;}
 if (brightnessFive > 244) {brightnessFive = 255;}
 if (brightnessFive < 1 ) {brightnessFive = 0 ;}

 
 // red
 analogWrite(ledOne, brightnessOne );
 // green
 analogWrite(ledTwo, pulseBrightness);
 
 // red
 analogWrite(ledThree, brightnessTwo);
 // green
 analogWrite(ledFour, pulseBrightness);
 
 // the wiring on this one is slightly different so the lights are reversed
 //green
 analogWrite(ledFive, pulseBrightness);
 // red
 analogWrite(ledSix, brightnessThree);
 
 // red
 analogWrite(ledSeven, brightnessFour);
 // green
 analogWrite(ledEight, pulseBrightness);
 
 // red
 analogWrite(ledNine, brightnessFive);
 // green
 analogWrite(ledTen, pulseBrightness);
 
 
 //////// output to max //////// 
 Serial.print(analogRead(one));
 Serial.print(",");
 Serial.print(analogRead(two));
 Serial.print(", ");
 Serial.print(analogRead(three));
 Serial.print(",");
 Serial.print(analogRead(four));
 Serial.print(", ");
 Serial.print(analogRead(five));
 Serial.print(",");
 Serial.print(analogRead(six));
 Serial.print(", ");
 Serial.print(analogRead(seven));
 Serial.print(",");
 Serial.print(analogRead(eight));
 Serial.print(", ");
 Serial.print(analogRead(nine));
 Serial.print(",");
 Serial.println(analogRead(ten));
}


Maxpatch video:
Here’s a quick video describing the Maxpatch behind this prototype. It is very similar to the one with 5 cans as I really liked the way in which that one worked and became very fond of the simple way in which it directly controls notes. I also grew quite fond of the chords used so decided to keep them the same.
 
Prototype 3 / Final Iteration

Leave a comment