-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimelapseServer.pde
43 lines (36 loc) · 890 Bytes
/
TimelapseServer.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import processing.net.*;
import processing.serial.*;
import java.io.*;
Serial serialPort;
int port = 10002;
Server myServer;
int speed = 2;
//192.168.0.102
void setup()
{
background(0);
myServer = new Server(this, port);
println("Server Started...");
println(Serial.list());
serialPort = new Serial(this, Serial.list()[2], 115200);//9600);
}
void draw()
{
// Get the next available client
Client client = myServer.available();
// If the client is not null, and says something, display what it said
if (client !=null) {
String clientData = client.readString();
if (clientData != null) {
for (int i = 0; i < clientData.length (); i++)
{
char charToSend = clientData.charAt(i);
for (int j = 0; j < speed; j++)
{
serialPort.write(charToSend);
}
println(charToSend);
}
}
}
}