Skip to content

Commit 02ce42f

Browse files
authored
Update ProcessingDefinitivo.pde
1 parent aa49047 commit 02ce42f

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

Processing/ProcessingDefinitivo.pde

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +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-
}
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"); ## Se configura el tiempo Unix
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+
}
5050
}

0 commit comments

Comments
 (0)