Friday, May 23, 2014

Final Project: Complete!

It’s time to hook up the whole system. The three of us met one final time to set up the flute (our lovely assistant, Box Cat) with grapes and the program Rebecca created to make this project interactive. While the Fruit Hero program was being finished, Amanda and I worked on getting the Arduino and breadboard into the box and ready for play. We ran into some interesting issues here, and we really had no idea why. We put the wires for the grapes up through the top of the box, and put the boards inside the box. We plugged a 9V battery into the board to see if we could make the system wireless, but then the program wasn't working. Touching the wires produced no sound. We thought the wiring was wrong, so we adjusted some things and tried again. Still no sound, or sometimes some notes would work and some wouldn't. We then plugged the board back into the computer, and it worked fine. We scratched our heads in awe, and then went to Google for answers.
20140520_142338
Wiring this was a pain.
Turns out, the problem is in the way the system is grounded. In this forum, a user explains that the system works fine if you touch the battery when touching the sensors, basically allowing your body and floor to be the grounding for the system. So when plugging it in to the computer, the computer acts as the grounding for the system. Pretty neat. Ultimately we went with the plug, since we need the Arduino to be talking and listening to the computer anyway for interaction.
Once Rebecca finished finalizing the Fruit Hero program, we hooked the two up together and played our new game. Read below to learn how we created the Fruit Hero program.
— From Rebecca’s blog, Arduino Hackers
Now we got the grapes playing notes, it’s time to send the note String data over to the computer.
Sending String data from the Arduino to the computer is very easy.
First you need to place this line of code in your setup method:
//Initialize serial communication at 9600 baud rate
Serial.begin(9600);
Then to send String data from the Arduino to Processing, you need to use this line of code:
Serial.println(“A”);
delay(10);//delay by 10 miliseconds so we don’t send the String data super crazy fast to Processing
For the purpose of our project, we placed it in the loop method, since we are listening for whenever a grape is touched to produce a note.
On the Processing side, we first need to import a library.  You can place this line of code before your setup method in Processing.
import processing.serial.*; //For Arduino to send over the String data to Processing
Then in your setup method, you need to place these lines of code:
//Get the port in the serial list
String portName = Serial.list()[5];// 5 – port number
myPort = new Serial(this, portName, 9600);
For my MacBook Pro laptop, port 5 is the one I am using on the Arduino side.  Your port will be different based on what computer you are using.  You can use this line to see what ports are available on your computer:
println(Serial.list()[5]); //5 is the port number.  To check, put in 0, 1, 2, etc. until you find the String printed out by this function to match the Serial port description for your Arduino Serial Port.  Mine is  /dev/tty.usbmodemfa131.  You can check what Serial Port you have by clicking on Tools -> Serial Port and see which one is checked.
Finally to get the String data value from the Arduino, you need these lines of code in your draw method:
//If we get data from serial port,
//then read it and store it in a variable
if(myPort.available() > 0)
{
serialPortValue = myPort.readStringUntil(‘\n’);
}
I used this tutorial to get this part working.
20140520_193755
Box Cat: Grapeless.
20140521_083634
Box Cat: Grapes.
















Some little details came in later, like adding in the “Call Me Maybe” music sheet and a color change for correct and incorrect notes. We also added in fireworks effects and celebration text to make the experience more dynamic. Since was the one who was best practiced at playing the "instrument," they had me demonstrate our project to the class, and they loved it. (Video available here)
Final Project – Complete. Thus, we end our time in Physical Computing.
You can view the entire project and its code here.

Final Project: Proof of Concept

It’s time to make this project interesting: we’re going to test out communication between an Arduino board and a piece of fruit. We had one lecture class on this process, so we talked to the teacher about how to do this. She drew a simple diagram, and then directed us to look at the CapSense tutorial.
The capacitiveSensor library turns two or more Arduino pins into a capacitive sensor, which can sense the electrical capacitance of the human body. All the sensor setup requires is a medium to high value resistor and a piece of wire and a small (to large) piece of aluminum foil on the end. At its most sensitive, the sensor will start to sense a hand or body inches away from the sensor.
We actually got this part working fairly quickly, testing with just one grape, then four, then all nine. This was rather quick. The next part can’t be too bad, right?
20140513_164502
The Grapes of Wrath.

Next: Polishing and the Fruit Hero program

Final Project: First Pass

“Create a coherent interactive experience that involves the Arduino communicating with another device (computer, 2nd Arduino, MIDI instrument, etc.).
Interactive = listening, thinking, and speaking from both parties. Whether it involves one cycle or many, the exchange should be engaging.”
Such are the specifications for our final project in Physical Computing. Amanda, Rebecca, and I teamed up once again to create another interesting and engaging piece. We decided to make Fruit Hero: an interactive music experience with a  fruity twist. We’re going to make a musical instrument using grapes as the keys, and a program that shows the player musical notes to match.
finalfritz
That’s the idea. No, you can’t import grapes into Fritzing.
The materials:
  • One Arduino Uno
  • Nine Grapes
  • One Speaker
  • Nine 1.5 Mohm Resistors (These are huge!)
Before getting our hands on grapes, we wanted to prototype with buttons to make sure our notes were going to be played correctly. Easy enough, we’ve worked with buttons before. Except that we all forgot how to use buttons on a board. So that took some getting used to, as well as some issues with the organization of button prongs. But eventually we got four buttons onto the board. But then the speaker didn’t work for some reason. After some tweaking, we got this small version working.
Then we wired another breadboard with four more buttons. We ran into some issues with this. Only one side was working. We rewired a few times to no avail. We couldn't figure out why only some of the buttons were working, and the other weren’t. So we disconnected one and it was working again, but of course with only four buttons. But what was the issue? Turns out, the small ground wire we were using to connect the board together was just a bit too short, so the other breadboard wasn’t being grounded. Oops. We switched out the wires and all nine buttons (we added in two modifier buttons for changes in octaves) were working splendidly.
Next step: Grapes.