16.INTERFACE AND APPLICATION PROGRAMMING

May 17, 2016

This week's assignment is to write an application that interfaces with an input &/or output device that you made, comparing as many tool options as possible.
I used input device that I made week11. And this assignment was my first try to develop interface and application, so it was too hard for me...

16-1.Test the force sensor

I tested my input device with the force sensor that I made in week11.

[Tools]
Software: Arduino / Processing

I opened Arduino and set each item in this way. Be sure to set "Clock" for "internal".

I connected my input device and FabISP,and put these USB cables in to PC.

[Arduino Code]

Then I wrote this code to Arduino, and executed command "Burn Bootloader".


The sensor reacted properly!


Next, I developed test application with Processing. I used Koichi Shiraishi's repo as reference because this is first time to use Processing.

[Processing Code]
I rewrote Koichi's code. And new code is able to change the color and the size of a circle when I press the sensor.



16-2.Develop the application(1)

I decided to make the application for doing finger snaps. (Because I've been practicing it since I was young, but I can't do finger snaps yet...) The plan of the system is that when the sensor which is attached to a palm is pushed with a finger, the application make a sound that is similar to finger snaps.

So I used " Minim" that is the library for Processing to make a sound.
"Minim is an audio library that uses the JavaSound API, a bit of Tritonus, and Javazoom’s MP3SPI to provide an easy to use audio library for people developing in the Processing environment. "

[Arduino Code]


[Processing Code]


I used a code same as "15-1." and downloaded a sound from this website.
Particularly, I thought out the part as below.
---
void draw(){
  if (myPort.available()>0){
    val = myPort.read();
    println(val);
    if (val < 15){ 
      background(r,val*15,val/r*15);
      snaps.trigger();  
      delay(100);
      myPort.clear();
    }
  }
---
If a value that is read by the sensor is smaller than "15", it make a sound. It was not entirely satisfactory that there was only a sound. So, at the same time, the color of window changes.


But, I noticed that this interface didn't make use of the characteristic of the force sensor and I had to use a switch....