I want my little ArduinoUno to listen to my remote linux server to see if the it is awake and I ran into problems. I have modified my little program to illustrate the problem, see below.When I send a character via the Arduino serial monitor the led toggles as expected, also when I send a character from gtkterm the led toggles as expected. In both cases the set baud rate doesn't matter.But when I in bash do echo a>/dev/ttyACM0, which is what I really want to to with cron, the led blinks for about a second and (mostly) returns to it previous state.Anyone knows how to write to /dev/ttyACM0 in bash? Any advice is appreciated? Håkan

/*This program is used to restart an Asus Eeepc when mains power returns after power and battery failure: connect ledpin via a diode to hot end of power switch, the Arduino should be powered by an independent power supply (USB may or may not deliver power after power down). When running the PC must emit at least one char every ten minutes to /dev/ttyACM0.*/boolean ledon = false; const int ledpin = 13; void setup() { pinMode(ledpin, OUTPUT); digitalWrite(ledpin, HIGH); Serial.begin(9600);}void loop() { if (ledon) digitalWrite(ledpin, LOW); else digitalWrite(ledpin, HIGH);}void serialEvent() { while (Serial.available()) { char inChar = (char)Serial.read(); } ledon=!ledon;}

Anyone knows how to write to /dev/ttyACM0 in bash? Any advice is appreciated?

By writing to the device you open it, the character gets sent and close it again. This shortly sets DTR which lets the Arduino reset (autoreset feature, that's necessary for a convenient upload functionality). Because that character is received by the Arduino during it's reset it doesn't have any consequences. On most Arduinos you can disable the autoreset feature by putting a 10µF capacitor between RST and GND.

Thanks a lot Pylon, now I grasp what is happening.If I am right to expect uninitialised variables to remain unchanged in memory during reset I believe I could do something like the sketch below, which seems to work.H

If I am right to expect uninitialised variables to remain unchanged in memory during reset

No, uninitialized variables are not in a defined state and at every reset they may have another state. Don't expect anything in the RAM to be the same after the reset as it was before the reset and if it is, you cannot rely on it.