Skip to content

Commit 0148492

Browse files
authored
Add files via upload
1 parent 52adf42 commit 0148492

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

Processing/ProcessingDefinitivo.pde

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import processing.serial.*;
2+
import de.bezier.data.sql.*;
3+
4+
Serial myPort;
5+
String val;
6+
MySQL db;
7+
int end = 10;
8+
int b = 0;
9+
int contador = 0;
10+
String serial, fecha;
11+
12+
void setup()
13+
{
14+
// On Windows machines, this generally opens COM1.
15+
printArray(Serial.list()[0]);
16+
myPort = new Serial(this, Serial.list()[0], 9600);
17+
18+
String user = "root";
19+
String pass = "";
20+
String database = "bdpython";
21+
db = new MySQL(this, "127.0.0.1", database, user, pass);
22+
}
23+
24+
void draw()
25+
{
26+
if (myPort.available() > 0 && b == 0){
27+
myPort.write("T1496245107");
28+
b++;
29+
}
30+
31+
val = myPort.readStringUntil('\n');
32+
33+
if (val != null){
34+
35+
val = trim (val);
36+
37+
if (val.contains("las")){
38+
fecha = val;
39+
}
40+
else {
41+
serial = val;
42+
}
43+
44+
if (contador %2 !=0){
45+
db.connect();
46+
db.execute("INSERT INTO example (data, hora) VALUES ('%s', '%s')", serial,fecha);
47+
}
48+
contador++;
49+
}
50+
}

Processing/sketch.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mode.id=processing.mode.java.JavaMode
2+
mode=Java

0 commit comments

Comments
 (0)