L2: Expressive Chaos

Krithin Sitaram (krithin@)
Amy Zhou (amyzhou@)
Daniel Chyan (dchyan@)
Jonathan Neilan (jneilan@)
Thomas Truongchau (ttruongc@)

Group 11

Expressive Chaos
Video Link
We built an instrument that combines multiple sensors that provides a unique experience for a performer to produce multiple sounds. We decided upon this design in order to challenge ourselves to use every sensor on the parts list and we believe we were successful in constructing this instrument. The final product does look a bit messy and it would be better if we had an enclosure in order to have a more pleasant looking instrument.

Instructions to Build:
Use 2 breadboards. On one breadboard, put flex sensor on the other breadboard, place the slide sensor, light sensor, and the button. The flex sensor, light sensor, and button are connected through pull-down resistors of 10k Ohms, 330 Ohms, and 330 Ohms respectively. Each are connected to an analog input pin.

Source Code:

const int INPINS[] = {A0, A1, A2, A3};
const int MAXVALUES[] = {950, 400, 1023, 320};
const int MINVALUES[] = {610,0,0,140};
const int BUZZER = 8;

void setup() {
  pinMode(BUZZER, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  for (int i = 0; i < 4; i++) { // hardcoded len(INPINS);
    double outtone = (analogRead(INPINS[i]) - MINVALUES[i]) * ((double)1000/(MAXVALUES[i] - MINVALUES[i])) + 440;
    tone(BUZZER, outtone, 100);
    Serial.println(analogRead(INPINS[i]));
      Serial.println(outtone);
    delay(130);
    noTone(BUZZER);

  }
  Serial.println();
  Serial.println();

}

Prototype 1: Expressive Maraca
Video Link
This instrument simulates a maraca electronically using an accelerometer and buzzer.

Source Code:

#include <Math.h>

const int groundpin = A2; // analog input pin 2
const int powerpin = A0; // analog input pin 0
const int xpin = A5; // x-axis of the accelerometer
const int ypin = A4; // y-axis
const int zpin = A3; // z-axis 
int BASELINE; // baseline for accelerometer

void setup()

{
 Serial.begin(9600);

 pinMode(groundpin, OUTPUT);
 pinMode(powerpin, OUTPUT);
 digitalWrite(groundpin, LOW); 
 digitalWrite(powerpin, HIGH);
 BASELINE = analogRead(xpin);

}

void loop()
{

 Serial.print(analogRead(xpin));  // print the sensor values:
 Serial.print("\t");  // print a tab between values:
 Serial.print(analogRead(ypin));
 Serial.print("\t");   // print a tab between values:
 Serial.print(analogRead(zpin));
 Serial.println();
 delay(5); // delay before next reading:

 double diff = fabs(analogRead(xpin) - BASELINE);
 if (diff > 150) {
    tone(10, 440);
    delay(10);
    noTone(10);
 }

}

Prototype 2: Expressive Siren
Video Link
This instrument produces a siren sound with an accelerometer and buzzer.

Source Code:

#include <Math.h>

const int groundpin = A2; // analog input pin 2
const int powerpin = A0; // analog input pin 0
const int xpin = A5; // x-axis of the accelerometer
const int ypin = A4; // y-axis
const int zpin = A3; // z-axis 
int YBASELINE; // baseline for accelerometer
int XBASELINE; 

void setup()

{
 Serial.begin(9600);

 pinMode(groundpin, OUTPUT);
 pinMode(powerpin, OUTPUT);
 digitalWrite(groundpin, LOW); 
 digitalWrite(powerpin, HIGH);
 XBASELINE = analogRead(xpin);
 YBASELINE = analogRead(ypin);
}

void loop()
{
 double xchange =  fabs(analogRead(xpin) - XBASELINE); 
 double ychange =  fabs(analogRead(ypin) - YBASELINE); 
 double diff = sqrt(xchange*xchange + ychange*ychange);

 double ytone = (analogRead(xpin) - 272) * (440/137) + 440;
 Serial.println(ytone);
 tone(10, ytone);

}

int roundToTenth(double a) {
  double t1 = a / 10;
  double t2 = floor(t1) * 10;
  Serial.print(t2);
  Serial.println();
  return t2;

}

Prototype 3: The Metronome (which becomes Expressive Chaos)
Video Link
This metronome turns into our Expressive Chaos instrument.

Source Code:

const int INPINS[] = {A0, A1, A2, A3};
const int MAXVALUES[] = {950, 1023, 1023, 320};
const int MINVALUES[] = {610,0,0,140};
const int BUZZER = 8;

void setup() {
  pinMode(BUZZER, OUTPUT);
  Serial.begin(9600);
}

void loop() {
    tone(BUZZER, 440, 100);
    delay(1000);
    noTone(BUZZER);

}

Parts List for Expressive Chaos
– 1 Flex Sensor
– 1 Slide Sensor
– 1 Photocell
– 2 Resistors – 330 Ohms
– 1 Resistor – 10k Ohms
– 1 Buzzer
– 1 Button
– 2 Breadboards
– Arduino