LCD
Purpose LCD screens can be used by an Arduino to display numbers and text
Wiring The screens communicate over a specific protocol called I2C It uses two communications pins, SDA and SCL On UNO boards, the A4 and A5 pins perform this task
Wiring
Wiring A4 and A5 SDA and SCL CIJE boards contain both: Either can be used
Libraries LCD’s contain 1,000’s of tiny independently controlled pixels Coding these independently would be impossible Instead we use a library Libraries can contain vast amounts of sub-coding, easily accessible using simple keywords For example: Tell Arduino to print the letter “A”, and the library inserts the coding necessary to control those pixels
Libraries The LCD library can be downloaded at theCIJE.org/Arduino
Libraries The downloaded file, in the form of a zip file, must be installed
Coding Within the void loop(), some commands you can use are: lcd.backlight(); // will turn on the blue backlight lcd.noBacklight(); // will turn off the blue backlight lcd.clear(); // will clear the screen lcd.setCursor(0,0); // move the cursor to cord. (x,y) lcd.print("Hello"); // prints "Hello" lcd.print(x); // prints the value of x
Coding Example If you had an integer "x" and it was equal to 96: lcd.clear(); lcd.setCursor(0,0); lcd.print("Hello, ARDUINO"); lcd.setCursor(0,1); lcd.print(x); Would display:
LAB Complete the LCD lab in Unit 12 of the textbook