Sunday, May 4, 2008

[prototype13_final]






































above: prototype in site and details of movement.
below: the overall apparatus.



detail of movement.


movement in site.


tactile interaction.

Labels: , , , ,


Tuesday, March 25, 2008

[prototype06_mysql to processing to pbasic to output]









Here, we have an LED responding to Air Quality Data being streamed over the internet and filtered through MYSQL. Processing is used to stream the data.
PROCESSING
import de.bezier.sql.*;
import de.bezier.mysql.*;

import processing.serial.*;


MySQL msql;

Serial myPort;

String table = "airTest";
String[] si = new String[636];

void setup()
{
size( 100, 100 );

println(Serial.list());
myPort = new Serial(this, "COM3", 2400);
//String user = "dbo238508103";
// String pass = "Ueb6pwb8";
// name of the database to use
//
//String database = "db238508103";



msql = new MySQL( "db192.perfora.NET", "db238508103", "dbo238508103", "Ueb6pwb8", this );

if ( msql.connect() )
{
// create a table with an id and a word
//
msql.execute( "CREATE TABLE IF NOT EXISTS " + table + " ("+
"id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,"+
"word VARCHAR( 255 )"+
")"
);




msql.query( "SELECT * FROM " + table );

int scount = 0;
while (msql.next())
{
String s = msql.getString("word");
si[scount] = s;
int n = msql.getInt("id");
println(s + " " + n);
float f = float(s);


scount = scount + 1;
}

// need to find out how many rows there are in table?
//
msql.query( "SELECT COUNT(*) FROM " + table );
msql.next();
println( "number of rows: " + msql.getInt(1) );
}
else
{
// connection failed !
}


}

void draw()
{

int gg = 0;
int f;

while(gg < f ="int(si[gg]);">0){

delay(1000);
println("port");
println(myPort.available());

if (myPort.available() == 0) {
delay(1000);
int x = int(si[gg]);
println(x);
myPort.write(x);
println("value");
println(si[gg]);
gg = gg + 1;
// myPort.stop();

PBASIC
'{$STAMP BS2}
'{$PBASIC 2.5}

x VAR Byte
y VAR Byte
proIn VAR Byte

Main:
DO

SERIN 16, 16780, [proIn]

IF proIn>10 THEN
LOW 2
ENDIF

IF proIn<10>
HIGH 2
ENDIF


IF proIn>20 THEN
LOW 3
ENDIF
IF proIn<30>
HIGH 3
ENDIF


IF proIn<30>
LOW 4
ENDIF
IF proIn>50 THEN
HIGH 4
ENDIF

IF proIn<50>
LOW 4
ENDIF
IF proIn>70 THEN
HIGH 4
ENDIF

LOOP
END

}

myPort.clear();
delay(1000);
}

}


Labels: , , ,


Wednesday, March 12, 2008

[prototype05_mysql to processing]





here we have a found code with our MYSQL data plugged in. when it is run it projects a stream of data. the draw portion(or the output) is not quite working.








PROCESSING
import de.bezier.mysql.*;


// created 2005-05-10 by fjenett
// updated 2005-11-16 by fjenett


MySQL msql;
void setup()
{
size( 100, 100 );
// this example assumes that you are running the
// mysql server locally (on "localhost").
//

// replace --username--, --password-- with your mysql-account.
//
//String user = "--username--";
//String pass = "--password--";

// name of the database to use
//
//String database = "--database--";

// name of the table that will be created
//
String table = "test";

// connect to database of server "localhost"
//
//msql = new MySQL( "localhost", database, user, pass, this );
msql = new MySQL( "SQL06.FREEMYSQL.NET", "ecovis", "fbitonti", "housebed202", this );
if ( msql.connect() )
{
// create a table with an id and a word
//
msql.execute( "CREATE TABLE IF NOT EXISTS " + table + " ("+
"id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,"+
"word VARCHAR( 255 )"+
")"
);

// fill the table with some data
//
msql.execute( "INSERT INTO " + table + " (word) VALUES (\"Lorem\")" );
msql.execute( "INSERT INTO " + table + " (word) VALUES (\"ipsum\")" );
msql.execute( "INSERT INTO " + table + " (word) VALUES (\"dolor\")" );

// now read it back out
//
msql.query( "SELECT * FROM " + table );

while (msql.next())
{
String s = msql.getString("word");
int n = msql.getInt("id");
println(s + " " + n);
}

// need to find out how many rows there are in table?
//
msql.query( "SELECT COUNT(*) FROM " + table );
msql.next();
println( "number of rows: " + msql.getInt(1) );
}
else
{
// connection failed !
}
}

void draw()
{
// i know this is not really a visual sketch ...
}

Labels: , ,


Tuesday, March 4, 2008

[prototype04_processing to microcontroller]


Getting two codes (PBASIC and Processing) to talk to each other. The first step in bringing remote data into the intelligence of a local device. This code communicates between the microcontroller and processing. When the mouse is pressed the LED turns on.

PROCESSING

// Example by Tom Igoe

import processing.serial.*;
int j=75;
Serial myPort; // The serial port
PFont myFont; // The display font
String inString; // Input string from serial port
int lf = 10; // ASCII linefeed

void setup() {
size(400,200);
// Make your own font. It's fun!
myFont = loadFont("ArialMT-48.vlw");
textFont(myFont, 48);
// List all the available serial ports:
println(Serial.list());

// I know that the first port in the serial list on my mac
// is always my Keyspan adaptor, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, "COM3", 2400);

}

void draw() {
// Twiddle your thumbs
background(0);

if(mousePressed== true) {

myPort.write(j);
println("test");

}

text("Received: " + inString, 10, 50);

//else {
//myPort.write(0);
// }
// int j=75;
// myPort.write(j);
// text("Received: " + inString, 10, 80);

//noLoop();
serialEvent(myPort);
}

void serialEvent(Serial myPort) {
inString = myPort.readString();
}

PBASIC


' {$STAMP BS2}
' {$PBASIC 2.5}

x VAR Byte
y VAR Byte
proIn VAR Byte

Main:
DO

SERIN 16, 16780, [proIn]

IF proIn = 65 THEN
LOW 2

ENDIF
IF proIn > 0 THEN

HIGH 2
ENDIF

LOOP
END

Labels: , ,


Tuesday, February 19, 2008

[prototype03_microcontroller to processing]

this week we made the micro controller communicate with the computer using Processing(rather than the computer sending the micro controller information).
using the photo resistor, a series of squares dance on the screen when exposed to light. when covered, the squares stop.
this test set up basic communication and understanding of code. 

next week we plan to import data into processing and make the micro controller react (basically opposite of todays video).
if the micro controller can respond to lists of data then we can begin to import live air quality updates.
import processing.serial.*;

int bgcolor; // Background color
color fgcolor; // Fill color
Serial port; // The serial port
int[] serialInArray = new int[100]; // Where we'll put what we receive
int serialCount = 0; // A count of how many bytes we receive
float xpos, ypos; // Starting position of the ball
boolean firstContact = false; // Whether we've heard from the microcontroller

void setup() {
size(256, 256); // Stage size
noStroke(); // No border on the next thing drawn

// Set the starting position of the ball (middle of the stage)
xpos = width;
ypos = height;

// Print a list of the serial ports, for debugging purposes:
println(Serial.list());


port = new Serial(this, "COM3", 9600);
port.write(65); // Send a capital A to start the microcontroller sending
}

void draw() {
background(bgcolor);

noStroke();
rect(xpos, ypos, 20, 20);
rect(xpos/2, ypos/2, 20, 20);
rect(xpos/4, ypos/4, 20, 20);
stroke(255);
//line(xpos, ypos, xpos*6, ypos*6);
// Get any new serial data
while (port.available() > 0) {
serialEvent();
// Note that we heard from the microntroller:
firstContact = true;
}
// If there's no serial data, send again until we get some.
// (in case you tend to start Processing before you start your
// external device):
if (firstContact == true) {

fill(162,211,177);

delay(200);
port.write(65);
}
}

void serialEvent() {
processByte((char)port.read());
}

void processByte(char inByte) {
// Add the latest byte from the serial port to array:
serialInArray[serialCount] = inByte;
serialCount++;
// If we have 3 bytes:
if (serialCount >2 ) {
xpos = (float)serialInArray[0];
ypos = (float)serialInArray[2];
fgcolor = (int)serialInArray[2];
// Send a capital A to request new sensor readings:
port.write(65);
// Reset serialCount:
serialCount = 0;
}

}


Labels: ,


This page is powered by Blogger. Isn't yours?