Hi guys,
my arduino code works but i have problems with my processing code. The code should gather one number from my website and send it to the arduino. It doesnt work sadly the way my processing code is written at the moment. Maybe you guys can take a look and help me with it.
Processing Code:
import processing.serial.*;
Serial ComPort;
String input[];
void setup(){
String portName = Serial.list() [0];
ComPort = new Serial(this, portName, 9600);
ComPort.bufferUntil('\n');
input = loadStrings("website-adresse");
if(input.length != 0){
String s_current = input[0];
int current = Integer.parseInt(s_current);
println(current);
delay(2000);
ComPort.write(current);
}
}
Arduino Code:
void setup() {
Serial.begin(9600); // Baudrate, muss mit PC übereinstimmen
pinMode(13,OUTPUT);
}
void loop() {
int c = Serial.read();
switch (c) {
case -1: return; // nichts neues gekommen, loop sofort beenden
case '0' :
digitalWrite(13, LOW);
break;
case '1' :
digitalWrite(13, HIGH);
break;
}
}
Greetings Jenni