0

I need to interface a weighing scale. I want to receive and transmit. While I'm connecting to the sensor on hyper terminal, it shows a single line.

If I'm connecting the sensor on Arduino, the values are printed line by line, like this:

sensor:12 
sensor:13 
sensor:14 
sensor:15 
sensor:16 
sensor:16

But I need a single line, like sensor:12.

While the sensor value changes, I need to print the same location line sensor:13.

Please help me.

  • Are you trying to say that you want a terminal display and that you want to update the value? – David Hoelzer Nov 21 '15 at 4:57
  • Have you tried ending each line with just a carriage return, "\r", instead of newline, "\n" ? Or you can print the \r at the beginning of each line. – James Waldby - jwpat7 Nov 21 '15 at 5:05
  • yes.....@David Hoelzer bro....... – Ilayaraja Raja Nov 21 '15 at 6:03
  • yes..........@David Hoelzer bro – Ilayaraja Raja Nov 21 '15 at 6:04
1

So what you want to do is to output the data without the newline character. So instead of using something like:

"sensor:%d\n"

in your code use:

"sensor:%d\r"

That will cause each reading to be output on the same line, starting from the left hand most position. If there is a chance that the readings will be of different lengths you might want to output something like:

"sensor:%d \r"

The spaces at the end will make sure that you don't have extraneous characters if, for example, your reading went from 100 to 99.

| improve this answer | |
0

This looks ok using screen on linux, should work on HyperTerminal too

#include <string.h>
int i, n ;
char *aux = (char*) calloc(3, sizeof(char));

void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.print("Sensor: ");
  for(i = 50; i >= 0; i--)  {
    sprintf(aux, "%2d", i);
    Serial.print(aux);
    delay(200);
    Serial.print("\b\b");
  }
  Serial.print('\r');
}
| improve this answer | |
0

Actually you are receiving different lines in both hyper terminal and Arduino.

It displays so due to the settings in the software. It is actually overwriting the previous line displayed with new line.

I didnt see any way to 'overwrite' the previous content displayed in arduino serial monitor.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.