CLS

Syntax:

    CLS

Command Availability:

Available on all microcontrollers.

Explanation:

The CLS command clears the contents of the LCD, and returns the cursor to the top left corner of the screen

Example :

        'A Flashing text "Hello World" program for GCBASIC

        'General hardware configuration
        #chip 16F877A, 20

        'LCD connection settings
        #define LCD_IO 8
        #define LCD_DATA_PORT PORTC
        #define LCD_RS PORTD.0
        #define LCD_RW PORTD.1
        #define LCD_Enable PORTD.2
        #define LCD_WIDTH 20                ;specified lcd width for clarity only.  20 is the default width


        'Main routine
        Do
            Print "Hello World"
            Wait 1 sec
            CLS          ' <<< the CLS instruction
            Wait 1 sec
        Loop

Key line: CLS — clears the whole display and returns the cursor to the top-left corner; since the loop calls Print again immediately afterward, the effect is text that flashes on and off every second.

See Also:

  • LCD Overview — LCD wiring and configuration background
  • Print — displaying text after clearing the screen, as used above
  • Locate — moving the cursor to a specific position instead of clearing the whole display

Supported in <LCD.H>