M
M
Mail-e2015-11-24 21:45:39
Arduino
Mail-e, 2015-11-24 21:45:39

Arduino how to clear port monitor?

A small program has been written that displays numbers in 1 column:
1
2
3
and so on, how to make the monitor have only one number? Namely, after the output of one number N, it was deleted and the next number was displayed

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
svd71, 2015-11-24
@Mail-e

No way to clear. Can be overwritten. For this, the Serial.print() method is used. At the end, you need to print the character 10 (0x0D) to return the carriage to the beginning.
Serial.println() at the end of each line automatically prints the combination of two characters 0x0D (Carriage Return) and 0x0A (Line feed)

V
vanyamba-electronics, 2015-12-04
@vanyamba-electronics

If you connect to an arduino using a VT100-compatible terminal, you can use escape sequences. For example like this:

void setup()
{
  Serial.begin(230400);
  Serial.print("\x1B[?25l");                        // Выключение курсора
}

void loop()
{
  unsigned char input = (analogRead(A0) >> 6);      // Чтение состояния входа Analog In 0 со сдвигом значения в диапазон [0..15]
  Serial.print("\x1B[0;0H|");                       // Курсор в позицию 0, 0
  for (unsigned char n = 0; n < 16; ++n) {          // Изображение шкалы
    Serial.print((n == input) ? '+' : '-');
  }
  Serial.print('|');
}

Download sketch .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question