Go Down

Topic: Problems with serial.print (Read 970 times) previous topic - next topic

Ivenhoe

Hi, I have this code.

Code: [Select]
int sum=0;
int b=20;

void setup() {
Serial.begin(9600);
 
}


void loop() {
  sum = sum + b;
 
 
  if (sum==800) {
   sum=0;
  }
 

    Serial.println(sum);
    delay(1000);

 
}


So I upload the code, start the serial monitor and I can see 20, 40, 60 etc.
I disconnect the serial monitor and connect again a couple of seconds later. I expect 240, 260, 280. But I can see it starts from the beginning with 20, 40 .... When I'm online with the serial monitor it works as expected.
Maybe anyone can tell me why?

thx in adavance

AWOL

Connection resets the Arduino.
You can disable this with a simple mod - check your board's documentation.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

eried

I modded the serial dll used for the com port enumeration, so you can use http://arduino.cc/forum/index.php/topic,118440.0.html to avoid disconnections when opening the arduino.
My website: http://ried.cl

InduinoX

What is the difference between serial.print and serial.printin ?

billroy

Println adds a linefeed at the end of the printed text so the next print will be on a new line.

-br

rujoking


What is the difference between serial.print and serial.printin ?


Note that it is println (with a lower-case L) and not printin (with a lower-case I).

Go Up