« Second Assignment : Typologies of Networks | Main | Third Assignment: Centrality »

Week 2 -Unintentional actions of your body

For this week assignment I decided to measure how many times I smile during my everyday. I think I am very conscious that I smile a lot but maybe too much??

Picture%209.png

Let's see. One way to measure the smile and facial expressions is using video tracking but I wanted to think of a sensor that allowed me to do it in another way. I choose a stretch sensor that measures changes in resistance ( variable resistor) if pushed/ stretch. The more stretched, higher is the resistance. It seemed for me that its use was more as an experience that a possible solution. ( and it's true!!). Not perfect at all but i got some results.

First I measured the resistance of the sensor using a multimeter in order to know how much of resistance I should use for the pull-down(up) resistor. The sensor that I used was giving me values which range(max, min) was very small but I decided to go on and experiment.

On the Arduino code, I used a smoothing (average of 20 readings) since the values of the readings of the sensor were fluctuating a lot.

I send the data from the sensor through serial to processing to demonstrate visually the act of smiling. After a while and passing through some small problems (mapping the values) I got a satisfied result :), even if the range is very small... (not enough significant difference btw min and mx values - normal state and smiling)

Picture%2010.png


Arduino Code:

int analogPin = 3;
int sensor;

#define NUMREADINGS 30
int readings[NUMREADINGS]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average


void setup() {
Serial.begin(9600);
for (int i = 0; i < NUMREADINGS; i++){
readings[i] = 0; // initialize all the readings to 0
}

}

void loop()
{
sensor = analogRead(analogPin)/2;

total -= readings[index]; // subtract the last reading
readings[index] = sensor; // read from the sensor
total += readings[index]; // add the reading to the total
index = (index + 1); // advance to the next index
if (index >= NUMREADINGS) // if we're at the end of the array...
index = 0; // ...wrap around to the beginning
average = total / NUMREADINGS; // calculate the average
Serial.print(average,BYTE); // send it to the computer (as ASCII digits)
}

Processing Code:

import processing.serial.*;
Serial myPort;
float sensor;

void setup(){
size(400,400);
println(Serial.list());
String portname = Serial.list()[0];
myPort = new Serial(this, portname, 9600);
sensor = 230;
}

void draw(){
background(255);
smooth();
fill(255,0,200);
noStroke();
ellipseMode(CENTER);
ellipse(200,200,350,350);
fill(0);
rect(120,150,30,30);
rect(250,150,30,30);
noFill();
stroke(0);
strokeWeight(20);
strokeCap(SQUARE);
bezier(80,230,120,sensor,280,sensor,320,230);

//mouseY 371(smile) - 250 ( liso) max = 374 initial position = 230
}

void serialEvent(Serial myPort) {
int sensorInput = myPort.read();
println(sensorInput);
sensor = map(sensorInput,88,95,230,371);
// VER OS VALORES QUE ESTAO A DAR E MUDAR 88 e 95
if(sensor < 230){
sensor = 230;
}
if ( sensor > 371){
sensor = 371;
}
println("sensor" + sensor);
}


TrackBack

TrackBack URL for this entry:
http://www.prntscreen.net/cgi-bin/mt/mt-tb.cgi/385

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on September 18, 2008 2:13 AM.

The previous post in this blog was Second Assignment : Typologies of Networks.

The next post in this blog is Third Assignment: Centrality.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35