Category Archives: Rest of You

Bed_Data

Bed Data project is something that we had been thinking about. I think we come up with the idea in summer 2009. Idea of visualizing sleep and sex sounds fun.

During summer we start building our force sensors. We were thinking about using 96 FSRs. That was so expensive so we build our own. Also we prepared a very nice documentation for DIY FSR (http://www.instructables.com/id/DIY-FSR-sandwich/)

Then next step was setting up a multiplexer shield.Our first iteration, we made a nice multiplexer shield for Arduino. It seems very cool.

However, we had some issues with multiplexers, then we decided to stick with breadboard.

breadboardBreadboard with multiplexer

For analog multiplexers (CD 4067) Tom Igoe has really good documentation on ITP physical computing page. Also,, I am planing to make an instructable for using multiple analog multiplexers.

Then we connected our sensors. We used ribbon cables (8wires) and terminals. So, we connected our sensors to terminals and terminal are connected to ribbon cables and they are connected to multiplexers. I think this is very modular setup and helped us a lot.

Then we tried to program our sensors. We are reading all the values by using Arduino Duemilanove. Then we are sending everything to processing. We have 3 different setup after this.

My program

I got all the sensor values, and but all the sensor into an order. First, I ran 20 loops to average sensor values. That helped me to remove the noise from sensors. In my code, for each run, I was looking at difference between this average value and sensor value and getting their difference according to a threshold. So, I had precise values.

Sensor values are changing their rectangular visuals color, white to black. Then I blur the image and and re size it.This helped me to map sensor values to pixels. Then I run blob tracking.

bedpicture3my blobs

Diego Rioja‘s program

He visualized each sensor as circles, circles are getting larger or smaller according to sensor values.

bedpicture Diegos Circles

Matt Richard’s Snake Game

Matt joined us in last minute. After talking with him for few hours, we decided to make a snake game. User need to roll his/her body up and down, left and right in the bed, to control the snake game. We projected the game to the ceiling, so user can watch it when he/she is laying down.

snakebedMatts game

a video that Diego shot

Rest of You Assignment 2

This is weeks assignment was to hook up one outwardly turned and one inwardly turned sensor and write them to a file. I used an electrode and an accelerometer (just x), and wrote my readings to a text file. I am trying to use MYSQL library to put them online. I think if I can solve my problems with creating a local host, it would not take that much time. I hope we’ll see one, running till next week.

sany0002

Accelerometer and electrode

sany0005

Arduino and breadboard set up

picture-141

Readings in a file

Rest of You assignment 2 from mustafa bagdatli on Vimeo.

video
This is my Arduino code:
/////////////Rest of You Assignemt 1////////////////////
/*
by Mustafa Bagdatli
09/21/2009
ITP fall 2009
*/

int analogPin = 0;
int analogValue = 0;            // outgoing ADC value
int analogPin2 = 1;
int analogValue2 = 0;            // outgoing ADC value

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
Serial.print(analogValue, DEC);
analogValue2 = analogRead(analogPin2);
Serial.print(“,”);
Serial.print(analogValue2, DEC);
Serial.println();
// pause for 10 milliseconds:
// delay(10);
}

This is my Processing Code:

/////////////Rest of You Assignemt 1////////////////////
/*
by Mustafa Bagdatli
09/27/2009
ITP fall 2009
*/

import processing.serial.*;
Serial port; // The serial port
int[] sensorValues = new int[2];

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

int x = 0;

FileOutputStream output;

void setup() {

size(800, 650);  // Stage size

port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list

port.bufferUntil(‘\n’);
// clear the serial buffer:
port.clear();

try {
output = new FileOutputStream(“logis.txt”, true);

}
catch (FileNotFoundException loui) {
loui.printStackTrace();
}

background(0);

}

void draw() {
for(int i = 0; i< sensorValues.length; i++){
sensorValues[i] = (int)map(sensorValues[i], 0,1023,0,height/2);
}
fill(0,255,0);
ellipse(x,height/2-sensorValues[0],3,3);
ellipse(x,height-sensorValues[1],3,3);
x = x+3;
if(x > width){
background(0);
x = 0;
}
}

void serialEvent(Serial port) {
// read the serial buffer:
String myString = port.readStringUntil(‘\n’);
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));
// make sure you have enough readings:
if (sensors.length >= sensorValues.length) {
// put the readings into the global array:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
if (sensorNum < sensorValues.length) {
sensorValues[sensorNum] = sensors[sensorNum];
String sensorVal =”sensor Number “+sensorNum+” : “+ sensorValues[sensorNum]+” “;
try {
output.write(sensorVal.getBytes(“UTF8″)); // Write the coordinate to the file

}
catch (Exception e) {
println(“Error: Can’t write file!”);
}

}
}
}
}
}


Rest of You Assignment 1

For this assignment all wee need to hook up some analog sensors and get values from them. I worked wit Asli for this one. I used an accelerometer (x-y) and a piezo. To make it more fun, I put the piezo on my Adams apple and accelerometer to my head and create a game. You need to get as many target as you can get in a minute. It is very simple when you start making sounds, your Adams apple vibrates and piezo gets values, this moves your cursor to right. and if you move your head up and down it moves your cursor down, and if you shake your head it picks up the target. If you are in the wrong place it creates a new target and your cursor goes to its initial point.

picture-14

initial game screen (cursor is the white ellipse on the first circle)

picture-16

trying to hit the target (cursor is on the 3rd row and 4th column)

sany0008

piezo sensor

sany0003

accelerometer

This is the arduino code for sensors:
/////////////Rest of You Assignemt 1////////////////////
/*
by Mustafa Bagdatli
09/21/2009
ITP fall 2009
*/

int analogPin = 0;
int analogValue = 0;            // outgoing ADC value
int analogPin2 = 1;
int analogValue2 = 0;            // outgoing ADC value
int analogPin3 = 2;
int analogValue3 = 0;            // outgoing ADC value
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
Serial.print(analogValue, DEC);
analogValue2 = analogRead(analogPin2);
Serial.print(“,”);
Serial.print(analogValue2, DEC);
analogValue3 = analogRead(analogPin3);
Serial.print(“,”);
Serial.print(analogValue3, DEC);
Serial.println();
// pause for 10 milliseconds:
// delay(10);
}

and this is the processing code for the game:

/////////////Rest of You Assignemt 1////////////////////
/*
by Mustafa Bagdatli
09/21/2009
ITP fall 2009
*/

import processing.serial.*;
Serial port; // The serial port
color c1;
int check = 0;
int preCheck = 0;
int[] sensorValues = new int[3];  // array to hold the sensor values
int d = 100;
int numXCircle;
int numYCircle;
int[] xCoor;
int[] yCoor ;
PFont font;
int xChoose;
int yChoose;
// The font must be located in the sketch’s
// “data” directory to load successfully
Boolean start = false;
color[] colorFill;
float xControl = 0.0;
float yControl = 0.0;
Boolean hit = false;
Boolean hitCheck = false;
int hitTime = 0;
int m = 60;
void setup() {

size(800, 650);  // Stage size
font = loadFont(“Helvetica-20.vlw”);
textFont(font);
port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list

port.bufferUntil(‘\n’);
// clear the serial buffer:
port.clear();

// Print a list of the serial ports, for debugging purposes to find out what your ports are called:
//println(Serial.list());    //
//noFill();
numXCircle = width / d;
numYCircle = (height / d);
xCoor = new int [numXCircle];
yCoor = new int[numYCircle];
colorFill = new color[numXCircle*numYCircle];
int x = d/2;
int y = d;
int yNum = 0;
int num = 0;
for(int i = 0; i < numXCircle; i++){

colorFill[num]  = color(random(0,230),random(0,230),random(0,230));

fill(colorFill[num]);

ellipse(x, y, d, d);
num++;
xCoor[i] = x;
yCoor[yNum] = y;
x = x+d;

if( i+1 == numXCircle  && yNum != numYCircle ){

yNum++;
if(yNum != numYCircle){
i = -1 ;
}
y = y+d;

x = d/2;
}

}
//fill(255);
xChoose = (int)random(0, numXCircle);
yChoose = (int)random(0, numYCircle);
println(xChoose);
text(“x”, xCoor[xChoose]-5, yCoor[yChoose]+5);

smooth();
}

void draw() {
control();
int num = 0;
background(0);

if(m ==0){
text(“Game Over”, width – 400, 30);
xControl = 0;
yControl = 0;

}
else{
m = (int)(60 – millis()*0.001);
}
fill(255);
text(“time: “+m, width-200, 30);
text(“score: “+ hitTime, width- 100, 30);

// if( start == false){

int x = d/2;
int y = d;
int yNum = 0;
for(int i = 0; i < numXCircle; i++){
//   fill(random(0,230),random(0,230),random(0,230));

fill(colorFill[num]);
ellipse(x, y, d, d);

num++;
x = x+d;

if( i+1 == numXCircle  && yNum != numYCircle){

yNum++;
if(yNum != numYCircle){
i = -1 ;
}
y = y+d;

x = d/2;
}
}
fill(255);

text(“x”, xCoor[xChoose]-5, yCoor[yChoose]+5);
//start = true;
//}
fill(240);
ellipse((d/2)+xControl,d+yControl,10,10);
float xEl = (d/2)+xControl;
float yEl = d+yControl;

if(hitCheck == true){
if(abs(xCoor[xChoose] – xEl) < 20 && abs(yCoor[yChoose]- yEl)<20){
hit = true;

}

}
if(hitCheck == true){
if(hit == true){
hitTime ++;
xControl = 0;
yControl = 0;
xChoose = (int)random(0, numXCircle);
yChoose = (int)random(0, numYCircle);

}
else{
xControl = 0;
yControl = 0;
xChoose = (int)random(0, numXCircle);
yChoose = (int)random(0, numYCircle);
hit = false;

}
println(hitCheck);
}

preCheck = check ;

hitCheck = false;

}

void serialEvent(Serial port) {
// read the serial buffer:
String myString = port.readStringUntil(‘\n’);
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));
// make sure you have enough readings:
if (sensors.length >= sensorValues.length) {
// put the readings into the global array:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
if (sensorNum < sensorValues.length) {
sensorValues[sensorNum] = sensors[sensorNum];
}
}
}
}
}

void control() {

println(sensorValues[2]);
if (sensorValues[1] > 600) {
yControl = yControl + 5;/////sensor val1
}
else if(sensorValues[0] > 0){
xControl = xControl +2*sensorValues[0];//////sensor Val0

}
else if (sensorValues[2] > 900){
hitCheck  = true;////sensor val2
}

}