Hello there,
I'm getting crazy finding information on something that I believe should be quite straightforward.
I want to be able to send and receive data to the Arduino serial port.
For now I'm simply trying to send a string "hello" that will light the LED for 1 second.
Everything works just fine IF the Arduino IDE is open and the serial monitor window opened.
As soon as a I close the serial monitor issuing a echo -n "hello" > /dev/tty… result in the terminal hang on the echo command, I have to terminate it with CTRL-C and I'm getting a "^C-bash: /dev/tty.usbmodem1d11: Input/output error"
I've tried originally with 9600 baud, then I've tried at 115200 try to following this: Arduino Playground - LinuxTTY but I've got the very same behavior.
Searching the internet or the forum about this matter does not lead anywhere…
What the IDE serial monitor do to the serial port? why if I close it down my computer I cannot send anymore the string successfully?
How can I then READ the output from the serial port?
This is the testing code I'm using on the Arduino:
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
String readString;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(115200);
Serial.println("serial test 0021"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(10);
if (Serial.available() >0) {
char c = Serial.read();
readString += c;}
}
if (readString.length() >0) {
Serial.println(readString);
if (readString=="hello"){
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.println("Led has blinked");
}
readString="";
}
}