Sensing Breath
This week's assignment was to "read some unintentional actions of your body." Using a stretch sensor, I created a device to monitor my breath rate, with the goal of helping to visualize my breathing and use it as a tool to learn to do steady, meditative breathing.
Arduino Code
int analogPin = 0; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
#define INTERVAL 100 // interval between readings, in milliseconds
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
delay(INTERVAL);
}
Processing Code
import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port
int sensor;
int adjustedsensor=sensor;
int xcoord=0;
int ycoord=50;
void setup() {
//println(Serial.list()); // List all the available serial ports
myPort = new Serial(this, Serial.list()[3], 9600);
myPort.bufferUntil('\n'); // read bytes into a buffer until
//you get a linefeed (ASCII 10)
size(700,300);
background(0);
smooth();
noStroke();
fill(80,130,50,55);
}
void draw() {
//background(0);
ellipse (xcoord+1,(sensor/1.75)-ycoord,10,10);
if (xcoord