Wednesday, December 12, 2012

Dec 12-Final Project


Digital Drum

Students
Brook Bowers, Computer Science
Mary White, Multimedia Marketing and Computing

Description
Digital drum is a pseudo drum head that also allows the user to play an interactive game. The game is an audible version of Simon. Our program plays a sequence of noises and the user is expected to replicate those noises by hitting the appropriate sensor.

Technical Details

Input
The input comes from the user tapping on the piezo sensors in each of the four corners. The input that the Arduino unit reads in is a series of readings of the sound wave generated by the tap. We programmed the Arduino unit to strip out short wavelength readings (to reduce outside noise from interfering). We also had the Arduino determine which sensor had been hit by determining the maximum value in the set of waves read in. We keep track of two pieces of data to transmit then, the number of readings for a particular wave (the magnitude of the hit) and the sensor that was hit (the quadrant). The quadrant and magnitude are then transmitted serially to Processing to specify which sensor was hit and the magnitude of the hit. That data is in turn used to determine struck the right instrument.

Output
Our output is sound played by Processing. We used the standard Processing minim library to load in and play sounds.

Construction
The Drum is constructed out of a sheet of hardboard, 4 piezo sensors, a sheet of acrylic, 4 plastic feet, and some foam core. First we drilled holes in the hardboard and ran the sensor wires through them, hot gluing a piezo in each corner. Then we glued the acrylic to each of the sensors to make sure that the readings would be accurate. Next we used the 3D printer to create feet for our drum head so that the breadboard and Arduino could fit underneath. After gluing these to the hardboard, we created a foam core box that holds the breadboard and Arduino in place so that the drum is portable.

Software
Some of our code is written in Arduino, but the majority of the code is written in 1.5.1 Processing. As stated before, the Arduino unit is programmed to read in the data from the piezo sensors and does a little bit of preprocessing before transmitting that data serially to Processing. There is only one key for our program:
            r: Resets the game back to round 1. The game does not reset on its own, and if a user cannot bear to feel the sting of defeat, then they may use this button to escape failure.

Wednesday, November 28, 2012

Nov 27 - More Final Project

So this week we've made a lot of progress with our project. We glued on the 3D printed feet, put together our hardware, taped the acrylic and board together to give us a consistent surface, and started working on the programming. Hardware wise, we're done. Now we just have to tackle the software.

So far, we only have the code we've worked with in Arduino. This basically just takes the input from the piezzos. Any time any of the buzzers give an output that is more than 10, four numbers (one for each buzzer) get printer in a line in the serial monitor.

Here's the bit of code we currently have:


const int sensorPin = 0;
const int ledPin = 13;
const int THRESHOLD = 100;

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

void loop()
{
  int inp0 = analogRead(A0);
  int inp1 = analogRead(A1);
  int inp2 = analogRead(A2);
  int inp3 = analogRead(A3);  
  
  if(inp0 > 10 || inp1 > 10 || inp2 > 10 || inp3 > 10) {
    Serial.println("Wave Detected!");
    while(inp0 > 10 || inp1 > 10 || inp2 > 10 || inp3 > 10){
      Serial.print(inp0);
      Serial.print(",");
      Serial.print(inp1);
      Serial.print(",");
      Serial.print(inp2);
      Serial.print(",");
      Serial.print(inp3);
      Serial.println();
      
      inp0 = analogRead(A0);
      inp1 = analogRead(A1);
      inp2 = analogRead(A2);
      inp3 = analogRead(A3);
      }
    Serial.println("Wave Ended!");
    }
}

The printing of Wave Detected and Wave Ended is simply a good visual for determining when there are vibrations and when there are not. 

Thursday we're going to start looking at how we are going to use Processing to create a visual display to go with our drum!

Nov 12-Another Final Project update

So after playing with the piezzo's, we grew worried that we might have to change our project. They were not very sensitive and weren't really picking up a whole lot of the vibrations very well. However, with the help of Dr. Hamid, we tried using a resistor with the piezzo's. Suddenly, everything worked brilliantly.

So now we have our four piezzos wired with header pins and we've cut out our acrylic and board. We also got four little rubber feet to raise up our board. We drilled the holes in our board to make it easy to run the wires through, and then superglued our piezzos onto the board. We also superglued the feet to the bottom of the board.

However, after putting the feet on, we realized that they were too short-we had calculated for the height of the breadboard, but hadn't considered the height of the wires coming out of the breadboard. So with some help, I designed new feet and printed them out on the 3D printer. They should be ready by next class period.

Currently, we've written a program that monitors the input from the sensors and gives us a print of the vibrations. It's a bit hard to read at the moment, but it tells us that each of the sensors are working properly. We'll work on formatting the output a bit better in the future.

Monday, November 12, 2012

Nov 8-Final Project Update

This week we've begun to work on our final project. We've sketched out a few drawings of what we want our drum head to look like and the materials that we will need.

Our drum will be made of two layers, one acrylic and one wood. In between these two layers, we will have four piezzo buzzers (one in each corner) to sense vibrations. These layers will be held together with electrical tape. We plan to run the wires through holes in the wood board so that the only thing visible from the top is the buzzers. The buzzers will each run to an analog pin in the arduino and then to ground. There will also be 4 small rubber feet in each corner to hold the board above the arduino and breadboard.

Nov 6-One Way Serial Communication

Introduction:
This week in lab, we were instructed to do an exercise involving one way serial communication. We were allowed to pick any two input sensors, so we decided to do ours utilizing piezzo buzzers since our final project will possibly involve using these sensors.

Procedure:
First, we hooked up a simple circuit with two piezzo buzzers. Next, we opened Arduino and created a program that would read the results from the sensors in the serial monitor. However the reading that this type of program was giving was just a string of random numbers, which was not helpful for our purposes. So we used CoolTerm to help make sense of the garbage.

Next we imported this to Processing. We used the bytes that were pulled in from the sensors and the Arduino to create a graph.

Here is a screenshot and a video:






Tuesday, October 30, 2012

Oct 30-Final Project

This week we were assigned to begin thinking about our final project and post a proposal. After much thought and discussion, my partner and I decided that we are going to make an interactive drum set. We will feed data from the drums via pressure sensors to our Arduino, and then use Processing to make the display. The idea is that depending on how hard and fast the drummer is hitting the pressure sensors, different colors and strokes will be displayed on the Processing canvas. This will be done by collecting the feedback from the pressure sensors and assigning them RGB values. It will also use some form of judgment in where the user is hitting to determine whether it should be creating a line or a circle. There will also be feedback for the user in the form of sound. This idea would utilize most of the things we have learned this semester and should yield a fun, interactive project.

Monday, October 29, 2012

Oct 27-Processing

Introduction:
This week, we were practicing using Processing. Processing is a Java based programming language that is especially helpful when producing graphs, images, and animations. Our assignment was to create some sort of image that involved an animation or interaction with either the mouse or keyboard. After thinking about what we wanted to create, we decided to go with an all time favorite-the head tilting Corgi. For those of you who may not be familiar with this phenomenon, here's a video:



Procedure:
The first step in creating our Corgi animation was to actually create our Corgi. We started by looking at various pictures of Corgwn to get a good idea of what shapes we would need to use. Next, we began to sketch out the shapes and how we wanted them oriented. Since neither I nor my partner are particularly talented artists, this took a while...

After we had sketched out how we wanted our Corgi to look, we started working within Processing to make our shapes and build our Corgi. We used a combination of rectangles, ellipses, and curves to make the basic structure.

After construction a Corgi that we were satisfied with, we decided it was time to make the animation. Originally we applied a rotation function directly to the head, using the mouseX and mouseY to determine how the head should be tilted. However, this made it to where the Corgi's head would tilt at odd angles and even entirely upside down. We also had issues with other parts of the Corgi rotating.

To solve the first problem, we introduced upper and lower limits to our Corgi's head. This prevents his head from tilting more than 90 degrees or PI/2 in either direction.

To fix the second issue, we wrapped our rotation in a pushMatrix and popMatrix. This isolates the rotation to only the head.

After our head tilt was working properly, we decided to make the enhancement that attaches a bone to the cursor. While functionally it has no purpose, it provides a cute visual enhancement to the program.

Here's a video of our program and our source code:




Conclusion:
This project, while a little silly, was a lot of fun and I really enjoyed being able to use Processing and create an interactive animation.