Advertisement
microrobotics

Character Display - LCD 2X8 - 5V White on Black (HD44780)

May 10th, 2023
1,315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This example will display "Hello!" on the first line of the LCD and the number of seconds since the Arduino was last reset on the second line. You can adjust this code to display any other text or variable values as per your requirements.
  3.  
  4. Remember to connect the LCD RS, E, and data lines (D4-D7) to the Arduino digital pins specified in the LiquidCrystal lcd(rs, en, d4, d5, d6, d7); line.
  5. */
  6.  
  7. #include <LiquidCrystal.h>
  8.  
  9. // Initialize the library by associating any needed LCD interface pin
  10. // with the arduino pin number it is connected to
  11. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  12. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  13.  
  14. void setup() {
  15.   // set up the LCD's number of columns and rows:
  16.   lcd.begin(8, 2);
  17.   // Print a message to the LCD
  18.   lcd.print("Hello!");
  19. }
  20.  
  21. void loop() {
  22.   // set the cursor to column 0, line 1
  23.   lcd.setCursor(0, 1);
  24.   // print the number of seconds since reset:
  25.   lcd.print(millis() / 1000);
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement