Hi,
at the moment i've created a small application to log data from the arduino and send it to a log file using linux
The code(messy) looks like this
int a [3] = {0,0,0};
int b [3] = {0,0,0};
int c [3] = {0,0,0};
int p0, p1, p2, time = 0;
void setup()
{
Serial.begin(1200);
}
void loop()
{
a[1] = analogRead(0);
b[1] = analogRead(1);
c[1] = analogRead(2);
delay(10);
a[2] = analogRead(0);
b[2] = analogRead(1);
c[2] = analogRead(2);
delay(10);
a[3] = analogRead(0);
b[3] = analogRead(1);
c[3] = analogRead(2);
p0 = (a[1]+a[2]+a[3])/3;
p1 = (b[1]+b[2]+b[3])/3;
p2 = (b[1]+b[2]+b[3])/3;
time = millis()/1000;
Serial.print(time);
Serial.print(",");
Serial.print(p0);
Serial.print(",");
Serial.print(p1);
Serial.print(",");
Serial.print(p2);
Serial.print("\n");
delay(980);
}
However, if i use the Arduino IDE, value time (function milli()) is reset each time i go to use the serial monitor. If i use a bash command such as cat /dev/ttyUSB0 value time has not been reset.
Do i have to echo something to my Arduino for milli to reset?
I believe the Arduino IDE sends a reset command to the Arduino when you open the Serial Monitor. So, the entire program is resetting, not just the millis().
I believe the Arduino IDE sends a reset command to the Arduino when you open the Serial Monitor. So, the entire program is resetting, not just the millis().
That is not true. the arduino is not aware of the monitor. it just sends data your way if you told it to do so with the serial library.
Looks to me like the IDE sends a reset when you connect the serial monitor and when you disconnect. I'm having the opposite problem. I'd like to turn the serial monitor on and off without resetting because I've gone to the trouble of coding up a real time clock. I even have 5 buttons connected to set the time. So I get it set to the correct time, but then it's back to the default time every time I click the serial port monitor in the IDE.
The Arduino IDE does not send a 'reset' when the serial monitor port is opened. However in the Arduino 0009 and later compatible hardware DTR (or RTS on boards made for the FTDI TTL-232R cable) gets asserted when the serial port is opened and a hardware reset is generated.
So, on the one hand, you are right in that a reset IS generated, BUT, on the other hand, you are wrong, because it IS NOT generated by the Arduino IDE.
Looks to me like the IDE sends a reset when you connect the serial monitor and when you disconnect. I'm having the opposite problem. I'd like to turn the serial monitor on and off without resetting because I've gone to the trouble of coding up a real time clock. I even have 5 buttons connected to set the time. So I get it set to the correct time, but then it's back to the default time every time I click the serial port monitor in the IDE.
I believe you want to to what regomodo is doing, cat /dev/ttyUSB0 from a unix command line, so that you monitor the port without the IDE.