Skip to main content
Arduino

Return to Answer

deleted 1 character in body
Source Link
Filip Franik
  • 1.3k
  • 1
  • 8
  • 22

The part of your code that prints data to the serial looks like this:

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.println(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}

The bug is in the Serial.println(angle); line. The println method inserts a "newsline""newline" character at the end. Try changing it to Serial.print(angle); so there is only one "newline" character.

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.print(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}

The part of your code that prints data to the serial looks like this:

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.println(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}

The bug is in the Serial.println(angle); line. The println method inserts a "newsline" character at the end. Try changing it to Serial.print(angle); so there is only one "newline" character.

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.print(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}

The part of your code that prints data to the serial looks like this:

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.println(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}

The bug is in the Serial.println(angle); line. The println method inserts a "newline" character at the end. Try changing it to Serial.print(angle); so there is only one "newline" character.

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.print(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}
Source Link
Filip Franik
  • 1.3k
  • 1
  • 8
  • 22

The part of your code that prints data to the serial looks like this:

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.println(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}

The bug is in the Serial.println(angle); line. The println method inserts a "newsline" character at the end. Try changing it to Serial.print(angle); so there is only one "newline" character.

void loop() {
 (...)
 Serial.print(sensorValue);
 Serial.print(" ")
 Serial.print(angle);
 (...)
 Serial.print(" ");
 Serial.println(led);
}
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /