Moving and sound emitting pair

The goal of this project is to explore how proximity of two objects can be used to modulate the nature of synthesized sound emitted from two objects. The objects are 3-d printed roly-poly shapes, each equipped with am Arduino Uno, Accelerometer, Speakers, and RFID controller, and two RFID transponder stickers. 

Sketches of shapes

Sketches of shapes

Enclosure

IMG_8587.JPG

I decided to make a 3-D model of an irregular oblong shape, reminiscent of an egg, using Rhino software. In creating this shape, I collaborated with Chester Dols, who is a mentor for this project. He taught me how to use Rhino and I admire his aesthetic, which aligns with mine. 

First, I printed the enclosure at 20% to see if it is structurally sound:

IMG_8593.JPG

I then printed it full size (about 5 inches in diameter) and had one succesful print, fillowrd by 4 failed attempts. The only printer that would print these is the .6 nozzle, which was then never free again. I have yet to schedule it and attempt to print the rest of the enclosures full size. Alternatively, I may try to print smaller enclosures in the .6 nozzle Ultimakers. 

IMG_8606.JPG

The components

Large GIF (416x228).gif

I'm using two accelerometers and RFID controllers to modulate the sound that eminates from the two objects. 

Sound

Option 1

I am using Max/MXP to create synth patches, which will be modulated by the serial input from the two accelerometers (via Arduino 101, which has a wifi shield) in the sculptures. The sculptures are roly-poly toy shapes that wobble when nudged - this is what creates the accelerometer values. Max will send the sound output via blue tooth to a bluetooth speakers that rest inside the sculptures themselves. Concern: I am a little worried there ill be lag when using wifi and bluetooth to send data back and fourth from the computer. 

Option 2

Another option that might produce immediate sound upon touch would be to use micro SD cards in an Arduino Uno. I am not sure if i could use the serial values of an accelerometer to modulate pre-recorded sounds. 

Another concern, is that the bluetooth speakers aren't loud enough. I will test this out. May need to get an amplifier. 

Code for Accelerometer 1: MMA_7455

#include <Wire.h>               //Include the Wire library
#include <MMA_7455.h>           //Include the MMA_7455 library

MMA_7455 accel = MMA_7455();    // Make MMA7455 object
int SpeakerOut = 9;
char xVal, yVal, zVal;          // Return value variables


void setup() {
  Serial.begin(9600);           // Use the Serial Monitor window at 9600 baud
  
  // Set the g force sensitivity: 2=2g, 4=4g, 8-8g
  accel.initSensitivity(2);
  
 // Provide oiffset values so that sensor displays 0, 0, 63
 //  (or close to it) when positioned on a flat surface, all pins
 //  facing down
 
 // Update the numbers with your own values from the MMA7455_CalibrateOffset sketch.
  accel.calibrateOffset(0, 0, 0);

  pinMode(SpeakerOut, OUTPUT);
}

void loop() {
 
  // Get the X, Y, anx Z axis values from the device
  xVal = accel.readAxis('x');   // Read X Axis
  yVal = accel.readAxis('y');   // Read Y Axis
  zVal = accel.readAxis('z');   // Read Z Axis
  
  // Display them in the Serial Monitor window.
  Serial.print("X: = ");
  Serial.print(xVal, DEC);
  Serial.print("   Y: = ");
  Serial.print(yVal, DEC);
  Serial.print("   Z: = ");
  Serial.println(zVal, DEC);
  delay(1000);

int frequency2 = map(yVal, -90, 90, 100, 680);


}
 

Code for Accelerometer 2 - ADXL335 - 5V

const int xInput = A3;
const int yInput = A1;
const int zInput = A2;
const int buttonPin = 2;
int SpeakerOut = 9;

// Raw Ranges:
// initialize to mid-range and allow calibration to
// find the minimum and maximum for each axis
int xRawMin = 0;
int xRawMax = 1024 / 2;

int yRawMin = 0;
int yRawMax = 1024 / 2;

int zRawMin = 0;
int zRawMax = 1024 / 2;

// Take multiple samples to reduce noise
const int sampleSize = 10;

void setup()
{
  //analogReference(EXTERNAL);
  Serial.begin(9600);
  pinMode(SpeakerOut, OUTPUT);
}

void loop()
{
  int xRaw = ReadAxis(xInput);
  int yRaw = ReadAxis(yInput);
  int zRaw = ReadAxis(zInput);

  if (digitalRead(buttonPin) == LOW)
  {
    AutoCalibrate(xRaw, yRaw, zRaw);
  }
  else
  {
    //    Serial.print("Raw Ranges: X: ");
    //    Serial.print(xRawMin);
    //    Serial.print("-");
    //    Serial.print(xRawMax);
    //
    //    Serial.print(", Y: ");
    //    Serial.print(yRawMin);
    //    Serial.print("-");
    //    Serial.print(yRawMax);
    //
    //    Serial.print(", Z: ");
    //    Serial.print(zRawMin);
    //    Serial.print("-");
    //    Serial.print(zRawMax);
    //    Serial.println();
    //    Serial.print(xRaw);
    //    Serial.print(", ");
    //    Serial.print(yRaw);
    //    Serial.print(", ");
    //    Serial.print(zRaw);

    // Convert raw values to 'milli-Gs"
    long xScaled = map(xRaw, xRawMin, xRawMax, -1000, 1000);
    long yScaled = map(yRaw, yRawMin, yRawMax, -1000, 1000);
    long zScaled = map(zRaw, zRawMin, zRawMax, -1000, 1000);

    // re-scale to fractional Gs
    float xAccel = xScaled / 1000.0;
    float yAccel = yScaled / 1000.0;
    float zAccel = zScaled / 1000.0;

    //    Serial.print(" :: ");
    //    Serial.print(xAccel);
    //    Serial.print("G, ");
    //    Serial.print(yAccel);
    //    Serial.print("G, ");
    //    Serial.print(zAccel);
    //    Serial.println("G");


    int frequency = 0;
    int frequency2 = 0;
    int frequency3 = 0;

    float totalAccel = 0;

    totalAccel = abs(xAccel) + abs(yAccel) + abs(zAccel);

    //frequency = map(xAccel, 0, 1, 100, 8700);
    frequency = map(xAccel, 0, 3, 100, 700);

    //Serial.println("xAccel: " + String(xAccel));
    Serial.println("totalAccel: " + String(totalAccel));
    //Serial.println("freq: " + String(frequency));


    //    if (xRaw < 350 || xRaw > 610 || yRaw > 600 || yRaw < -430) {


    //dont make a sound when its not moving
    if (totalAccel < 3.3 || totalAccel > 3.5) {
      tone(SpeakerOut, frequency);
      delay(10);
    }
    else {
      //mute it
      noTone(SpeakerOut);
      delay(10);
    }

  }
}


//end if


// Read "sampleSize" samples and report the average
//
int ReadAxis(int axisPin)
{
  long reading = 0;
  analogRead(axisPin);
  delay(1);
  for (int i = 0; i < sampleSize; i++)
  {
    reading += analogRead(axisPin);
  }
  return reading / sampleSize;
}

//
// Find the extreme raw readings from each axis
//

void AutoCalibrate(int xRaw, int yRaw, int zRaw)
{
  Serial.println("Calibrate");
  if (xRaw < xRawMin)
  {
    xRawMin = xRaw;
  }
  if (xRaw > xRawMax)
  {
    xRawMax = xRaw;
  }

  if (yRaw < yRawMin)
  {
    yRawMin = yRaw;
  }
  if (yRaw > yRawMax)

  {
    yRawMax = yRaw;
  }

  if (zRaw < zRawMin)
  {
    zRawMin = zRaw;
  }
  if (zRaw > zRawMax)
  {
    zRawMax = zRaw;
  }
}