14. Interface and Application Programming¶
This week’s individual assignment is to write an application that interfaces a user with an input &/or output device that you made.
I used the sound sensor board and t3216 breakout board which I made.
I tried Blynk as written in 1. Switch On and Off from iPhone (Ishimura) section.
Sound sensor & Processing¶
I ran the program which was used to test my Sound Sensor board uploading to t3216 from Ardunino IDE and showing the result on a browser by Processing.
I followed below steps.
1. Cabling the t3216 and the sensor board
Board | 1 | 2 | 3 |
---|---|---|---|
Sound sensor | VCC | GND | OUT |
t3216 | VCC | GND | PA7 |
2. Activate the program in Arduino
Code
// Connect the MEMS AUD output to the t3216 breakout board PA7 pin
int mic = A7; //tentatively change from A7
// Variable to hold analog values from mic
int micOut;
void setup() {
Serial.begin(9600);
}
void loop() {
// read the input on analog pin 0:
micOut = analogRead(mic);
// print out the value you read:
Serial.println(micOut);
}
3. Install Processing
4. Run Processing Program
-
Current Port is “/dev/cu.usbserial-D307RGA2”
-
Code
import processing.serial.*;
Serial port;
float x;
float y;
int in_data;
void setup() {
size(300, 300);
port = new Serial(this, "/dev/cu.usbserial-D307RGA2", 9600);
background(0, 0, 0);
}
void draw() {
// set drawing area
fill(255, 10);
noStroke();
rect(0, 0, width, height);
// receive data from serial port
if (port.available() > 0 ) {
// receipt of serial data
in_data = port.read();
// drawing
x = width / 2 + random(-3, 3);
y = height / 2 + random(-3, 3);
noFill();
stroke(random(255), random(255), 255);
ellipse(x, y, in_data, in_data);
}
}
## Results
Sound sensor is catching sounds and Processing is drawing in browser.
Learnings¶
I had been thought that applications which is working on iPhone and Browser are too difficult for me to handle before this session. This week I had experiences of Processing and Blynk(as Group assignment). They were very handy and so interesting. I’d like to make good use of one of them in my Final Project.
Notes :
- We cannot open Serial Monitor of Arduino and Processing drawing at the same time.
- We need start from Arduino, then work on Processing.
Reference site( in Japanese ):
ArduinoとProcessingを連携させてシリアルデータをやり取りする