Hey everyone ![]()
So i need a little bit of help with serial communication between Processing and the Arduino ![]()
Basically, i want to display text on a 16x2 LCD on my arduino from a textbox on a webpage so that everyone can leave a message.
So far i've managed to create a text file from that textbox and recover it in Processing.
I also know how to use the 16x2 LCD on the arduino.
The problem i have is that i can't find a solution to get that text from Processing and send it to the arduino even though i've been searching for hours ![]()
Here is the Processing code :
http://pastebin.com/mzZ0NVNw
import processing.serial.*;
Serial port;
void setup() {
port = new Serial(this, Serial.list()[1], 9600);
}
void draw() {
String texte[] = loadStrings("http://icore.alwaysdata.net/data.txt");
//println(texte[0]);
//port.write(texte[0]);
char[] strChar;
strChar = texte[0].toCharArray();
for (int i=0 ; i <= texte.length +1 ; i++) {
println(strChar[i]);
delay(1000);
}
delay(5000);
}
Here is the Arduino code :
const int ledPin = 13; // the pin that the LED is attached to - change this if you have a separate LED connected to another pin
String inData;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
while (Serial.available() > 0) {
char received = Serial.read();
inData += received;
//inData = "";
}
if (inData == "cac") {
digitalWrite(ledPin, HIGH);
}
if (inData == "lol") {
digitalWrite(ledPin, LOW);
}
inData = ""; // Clear received buffer
}