Clearing the terminal screen?

后端 未结 14 2392
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 07:03

I\'m reading data from 9 different sensors for my robot and I need to display them all steadily, in the same window so I can compare the values and see if any of the reading

相关标签:
14条回答
  • 2020-12-29 07:42

    There is no way to clear the screen but, a really easy way to fake it can be printing as much Serial.println(); as you need to keep all the old data out of the screen.

    0 讨论(0)
  • 2020-12-29 07:44

    I made this simple function to achieve this:

    void clearscreen() { 
        for(int i=0; i<10; i++) {
            Serial.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
        }
    }
    

    It works well for me in the default terminal

    0 讨论(0)
  • 2020-12-29 07:45

    the best way I can think of is using processing there are a few introductions on the net like displaying serial data, arduino graph and arduino radar
    Since Arduino is based on processing its not that hard to learn

    0 讨论(0)
  • 2020-12-29 07:50

    The Arduino serial monitor isn't a regular terminal so its not possible to clear the screen using standard terminal commands. I suggest using an actual terminal emulator, like Putty.

    The command for clearing a terminal screen is ESC[2J

    To accomplish in Arduino code:

      Serial.write(27);       // ESC command
      Serial.print("[2J");    // clear screen command
      Serial.write(27);
      Serial.print("[H");     // cursor to home command
    

    Source:
    http://www.instructables.com/id/A-Wirelessly-Controlled-Arduino-Powered-Message-B/step6/Useful-Code-Explained-Clearing-a-Serial-Terminal/

    0 讨论(0)
  • 2020-12-29 07:52

    You could just do:

    Serial.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    

    or if you want:

    for (int i=0; i<100; i++) {
       Serial.print("\n");
    }
    
    0 讨论(0)
  • 2020-12-29 07:52
    /*
    As close as I can get to Clear Screen
    
    */
    
    
    void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    
    }
    
    void loop() {
    
    Serial.println("This is Line ZERO ");
    
    // put your main code here, to run repeatedly:
    
    for (int i = 1; i < 37; i++)
    {
    
     // Check and print Line
      if (i == 15)
      {
       Serial.println("Line 15");
      }
    
      else
       Serial.println(i);  //Prints line numbers   Delete i for blank line
      }
    
      delay(5000);  
    
      }
    
    0 讨论(0)
提交回复
热议问题