Thursday, December 13, 2007

final code

Processing code:

import de.bezier.sql.*;
import de.bezier.mysql.*;

import processing.serial.*;


MySQL msql;

Serial myPort;

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

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

println(Serial.list());
myPort = new Serial(this, Serial.list()[1], 2400);



msql = new MySQL( "SQL06.db4free.NET", "ecovis", "fbitonti", "glight", 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;

while(gg < 636){
int f = int(si[gg]);
if(f>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();


}

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

}
}


PBASIC CODE:

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

check VAR Byte
proIn VAR Byte

Main:
DO
check = IN3
proIn = IN10

HIGH 2
HIGH 6
HIGH 8
HIGH 11

SERIN 16, 16780, [proIn]
IF proIn > 0 THEN
IF proIn < 13 THEN

'DO WHILE proIN < 13

HIGH 2
HIGH 6
HIGH 8
HIGH 11
PAUSE 9000

' SERIN 16, 16780, [proIn]
' LOOP
' END
ENDIF
ENDIF

IF proIn > 13 THEN
IF proIn < 20 THEN
' DO WHILE proIn > 13
HIGH 2
HIGH 6
HIGH 8
HIGH 11
PAUSE 200
LOW 2
LOW 6
LOW 8
LOW 11
PAUSE 200
HIGH 2
HIGH 6
HIGH 8
HIGH 11
PAUSE 200
LOW 2
LOW 6
LOW 8
LOW 11
PAUSE 500

'LOOP
'END
ENDIF
ENDIF

IF proIn > 20 THEN
IF proIn < 50 THEN
' DO WHILE proIn > 13
HIGH 2
HIGH 6
HIGH 8
HIGH 11
PAUSE 200
LOW 2
LOW 6
LOW 8
LOW 11
PAUSE 200
HIGH 2
HIGH 6
HIGH 8
HIGH 11
PAUSE 200
LOW 2
LOW 6
LOW 8
LOW 11
PAUSE 200
HIGH 2
HIGH 6
HIGH 8
HIGH 11
PAUSE 200
LOW 2
LOW 6
LOW 8
LOW 11
PAUSE 500

'LOOP
'END
ENDIF
ENDIF



LOOP
END

Labels:


Comments: Post a Comment



<< Home

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