Sound sculpture prototype with Arduino and accelerometer

 

Part 1.  10/2/17.

Using tape and plaster is not ideal. My next steps are: making smooth, sandable sculptures using styrofoam and clay, then casting them in a foam resin that will allow for sound to travel from inside the enclosure. 

 

 

 

Part 2. Update. 10/9/17.

I made a roly-poly enclosure so that it can move and make music on it's own when pushed. I used plaster to create a heavy center of mass on the bottom.

 

I am happy with the fact that the rolly polly effect is working. The rolling could be smoother and the shell more polished. I have yet to try 3d printing and resin casting for these shapes. Questions remain:

1. What's the best way to fasten the Arduno inside the shape? 

2. How do I make it so that the Arduino turns off on it's own when the shape isn't moving - do i have to use a button or can it shut off and on by movement activation? Perhaps a touch sensor can act as a button.

I think the easiest way to make an enclosure that can open and close easily is to download a 3d printable container with a screw lid, then modify the top of the lid and body of the jar using Blender. The result would be a shape that opens and closes without a noticeable, distracting latch. 

 

Sound

For the first pass I'm happy with the synth sound. For the next iteration, I'd like to try to use the Mozzi library to create some more variation of sound and manipulate the relationship between current and sound mapping so that it's not mapped linearly. Perhaps some unexpected inverse relationship can be explored. 

 

Code

I found a library in the documentation that came with my accelerometer and used it in my own code, which used the variables that the accelerometer produced to manipulate the frequency of sound synthesized by the speaker. 

 

#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);


}

   
   

Analog Input

Lab Exercise 1

For this Lab exercise, I set up my Arduino to read and print out the voltage readings of a switch, a potentiometer, and a photocell.   

switch_sm.gif
lightsensor_sm.gif

Code:

 

void setup() {
  // ppin mode
  pinMode(8, INPUT); //set switch's pin 8 to be input
  Serial.begin(9600); //initialize serial communications
  
  

}

void loop() {
  int SwitchState = digitalRead(8); //read the switch
  int potState = analogRead(A0); // Read the potentiometer
  // you should pause for a a millisecond b/w two analog reads. 
  //Turns out that arduino has only one to analog converter so can only do 2 at a time
  //so you need to reset it using this bit of time, this helps get a reliable read on the second analog read
 
  delay(1);  
  int photoCellState = analogRead(A1); // read the photocell

  //print them all out
  Serial.print("switch: ");
 
  Serial.print(SwitchState);
      Serial.print("\t"); //print a tab
  
  
  Serial.print("potState: ");
  Serial.print(potState);
      Serial.print("\t"); //print a tab
  
  Serial.print("photoCellState: ");
  Serial.println(photoCellState); //like enter return when typing
    


}

Lab Exercise 2

After completing lab exercise 2 - using digital or analog input and digital output, I came up with an application: The pressure sensor served as a weighing mechanism for objects I had around. The analog input was the weight of the objects and the digital output was the strings of words written by the Serial print monitor that corresponded to the weight range I assigned. I used an "if / else" statement for this.

if (lightness < 3)
{
Serial.println("Try a heavier one");
   Serial.print("\t"); 
 
}
else  {
  Serial.println("YOU DID IT");