Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- To interface with a HD44780 parallel interface LCD, you can use the LiquidCrystal library that comes with the Arduino IDE.
- This example uses a 4-bit interface, meaning it sends data 4 bits at a time. It connects the LCD RS, E, and data lines (D4-D7) to the Arduino digital pins. It uses the LiquidCrystal(rs, enable, d4, d5, d6, d7) function to initialize the library.
- In the setup() function, it calls lcd.begin(16, 2) to set up the LCD's number of columns and rows. It then prints "Hello, World!" to the first line of the display.
- The loop() function sets the cursor to the beginning of the second line with lcd.setCursor(0, 1) and then prints the number of seconds since the Arduino was last reset.
- Make sure to replace the pin numbers in the LiquidCrystal lcd(rs, en, d4, d5, d6, d7); line with the actual pin numbers you're using.
- Here is a simple example of how to display "Hello, World!" on a 2x16 LCD:
- */
- #include <LiquidCrystal.h>
- // Initialize the library by associating any needed LCD interface pin
- // with the arduino pin number it is connected to
- const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD
- lcd.print("Hello, World!");
- }
- void loop() {
- // set the cursor to column 0, line 1
- lcd.setCursor(0, 1);
- // print the number of seconds since reset:
- lcd.print(millis() / 1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement