THE CUBE
An interactive PCOM project that uses an accelerometer and MP3 Shield to play some surprising sounds as you turned the cube up, down, left and right. We were assigned into groups of 2 for this project and I was paired up with Yanlin Ma.
THE SKETCH
During our brainstorm for project ideas, Yanlin came up with the idea to contrast the shape of a cube with the sounds of bouncing balls. We wanted to add 3 buttons to toggle between 3 different sound types: a rubber ball, a metal ball and a wooden ball. In this iteration, I wanted to place the buttons discretely in the corner, while Yanlin preferred the button in the center with a hole for the wire to the computer or power source in the corner.
MP3 SHIELD, 8 OLM SPEAKER WITH SD CARD
The first step in executing the idea was to get our accelerometer working to get precise sensor readings of the X, Y, Z values. Yanlin and I also worked separately in trying to get precise sensor readings on our devices, and were both having problems with our accelerometer. I was getting inconsistent readings or very slight changes in the sensor readings, so Yanlin advised me to solder the pins on my accelerometer and that worked. For sound, we needed to find or record our MP3 or WAVE sounds to map the accelerometer to. We found a site called audioblocks.com and really liked their sound effects and loops. We then decided to use MP3 files and found the MP3 shield to use with our Arduino.
ENCLOSURE, BATTERY, MP3 SHIELD AND ARDUINO
For the enclosure, we wanted the box to be black acrylic. I found a place in Pennsylvania, misterplexi that sells lots of different kinds of plexi boxes in different colors. Unfortunately, they didn’t have the black boxes in stock and by the time they could ship them, it would be too late, so I ended up buying clear baseball display boxes from The Container Store and painting them with a matte black acrylic paint from Blick Paint. Since I didn’t take a fabrication class (which I eventually should), I wanted to avoid drilling holes for switches and wires, so I decided to use a 9V battery to keep everything enclosed inside the black cube and making it easier for people to hold and move around. I soldered the red and black wires of the battery snap to wire that could plug into the power connector.
INSIDE THE CUBE
HOW IT WORKS
PCOM – Mid-Term Project from annemgal on Vimeo.
MP3SHIELD_PCOM_MIDTERM SKETCH —————————————————————————————— #include <SoftwareSerial.h> #include "MP3.h" /** define mp3 class */ MP3 mp3; int up = 0; int down = 0; int left = 0; int right = 0; void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); /** begin function */ mp3.begin(MP3_SOFTWARE_SERIAL); // select software serial // mp3.begin(); // select hardware serial(or mp3.begin(MP3_HARDWARE_SERIAL);) // in hexadecimal /** set volum to the MAX */ //mp3.volume(0x1F); mp3.volume(0x16); // signal when ready mp3.set_mode(MP3::SINGLE); mp3.play_sd(0x0001); /** set MP3 Shield CYCLE mode */ //mp3.set_mode(MP3::CYCLE); mp3.set_mode(MP3::REPEAT); /** play music in sd, '0001' for first music */ //mp3.play_sd(0x0001); // 1: clank // 2: metal rolling // 3: metal dropping // 4: rubber dropping // 8: ball roll /** play music in USB-disk */ //mp3.play_usb_disk(0x0001); /** play music in SPI FLASH */ //mp3.play_spi_flash(0x0001); } void loop() { /** function code here */ // read the input on analog pin 0: int sensorValueZ = analogRead(A0); // print out the value you read: Serial.print(sensorValueZ); Serial.print(","); // read the sensor: int sensorValueY = analogRead(A1); // print the results: Serial.print(sensorValueY); Serial.print(","); // read the sensor: int sensorValueX = analogRead(A2); // p rint the results: Serial.println(sensorValueX); //////////////////////////////////////////////// /** play music in sd, '0001' for first music */ if (up){ if (sensorValueX < 550){ mp3.stop(); } } if (sensorValueX > 550){ if (!up){ mp3.play_sd(0x0008); up = 1; down = 0; left = 0; right = 0; } } else if (sensorValueX < 450){ if (!down){ mp3.play_sd(0x0002); up = 0; down = 1; left = 0; right = 0; } } else if (sensorValueY > 550){ if (!left){ mp3.play_sd(0x0003); up = 0; down = 0; left = 1; right = 0; } } else if (sensorValueY < 450){ if (!right){ mp3.play_sd(0x0004); up = 0; down = 0; left = 0; right = 1; } } else{ mp3.stop(); up = 0; down = 0; left = 0; right = 0; } // 1: clank // 2: metal rolling // 3: metal dropping // 4: rubber dropping ///////////////////////////////////////////// // in milliseconds // slow down so p5 can keep up delay(100); // delay in between reads for stability }
You must be logged in to post a comment.