Send frameCount to arduino
in
Integration and Hardware
•
2 years ago
I want to do something that should be simple, i only have been strumbling for hours...
I just want to send the frameCount of the processing sketch to arduino, and then send it back.
Then i want the frameCount value in the Serial monitor and when it get's send back in the processing console.
Arduino code:
Serial monitor:
1
2
3
4
6
8
0
1
2
1151671
120
processing console:
5
7
9
1
I just want to send the frameCount of the processing sketch to arduino, and then send it back.
Then i want the frameCount value in the Serial monitor and when it get's send back in the processing console.
Arduino code:
- void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
Serial.println(Serial.read());
}
}
- import processing.serial.*;
Serial port;
String inString;
void setup() {
frameRate(1);
println(Serial.list());
port = new Serial(this, Serial.list()[1], 9600);
port.bufferUntil('\n');
}
void draw() {
port.write(frameCount);
println(inString);
}
void serialEvent(Serial port) {
inString = port.readString();
}
Serial monitor:
1
2
3
4
6
8
0
1
2
1151671
120
processing console:
5
7
9
1
1