I'm running a bash script on Ubuntu 10.04 to send a simple on/off message via serial to an Arduino Diecimila.
Here's the bash script (called with an argument of either 1 or 0 to turn on and off):
#!/bin/bash
#configure the serial connection to talk to the arduino
stty -F /dev/ttyUSB0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
echo -n $1 > /dev/ttyUSB0
exit 0
and here's the sketch:
int incomingByte = 0;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte == 49 )
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
}
}
The problem is that after rebooting the PC, the arduino doesn't respond to the serial command. The serial LED flashes briefly on the board, but the LED is not lit. If I run the Arduino IDE programme and start the serial monitor, then the bash script works, even after exiting the IDE. I also have the same problem with a python script. Is there a command needed to open the connection?
Can anyone help with this?
thanks
James