Arduino-LCD
LCD library for Arduino
Demo.ino
Go to the documentation of this file.
1 #include "GPIO.h"
2 #include "TWI.h"
3 #include "Hardware/TWI.h"
4 #include "Software/TWI.h"
5 #include "LCD.h"
6 #include "Driver/MAX72XX.h"
7 #include "Driver/PCD8544.h"
8 #include "Driver/HD44780.h"
9 #include "Adapter/Debug.h"
10 #include "Adapter/PP7W.h"
11 #include "Adapter/SR3W.h"
12 #include "Adapter/SR4W.h"
13 #include "Adapter/MJKDZ.h"
14 #include "Adapter/GY_IICLCD.h"
15 #include "Adapter/DFRobot_IIC.h"
16 #include "Shield/LCD4884.h"
17 #include "Shield/LCD_Keypad.h"
18 
19 // Configure: HD44780 Adapter; Debug, PP7W, SR3W or TWI PCF8574
20 // LCD::Debug io(Serial);
21 // LCD::PP7W<BOARD::D4, BOARD::D5, BOARD::D6, BOARD::D7, BOARD::D8, BOARD::D9, BOARD::D10> io;
22 // LCD::SR3W<BOARD::D7, BOARD::D6, BOARD::D5> io;
23 // LCD::SR4W<BOARD::D7, BOARD::D6, BOARD::D5, BOARD::D4> io;
24 // Software::TWI<BOARD::D8, BOARD::D9> twi;
25 // Software::TWI<BOARD::D18, BOARD::D19> twi;
26 Hardware::TWI twi(100000UL);
27 // Hardware::TWI twi(400000UL);
28 // LCD::MJKDZ io(twi);
30 // LCD::DFRobot_IIC io(twi);
31 
32 // Configure: LCD; HD44780, MAX72XX, or PCD8544, LCD4884 or LCD_Keypad
33 HD44780 lcd(io);
34 // MAX72XX<BOARD::D10, BOARD::D11, BOARD::D13> lcd;
35 // PCD8544<BAORD::D5, BOARD::D4, BOARD::D3, BOARD::D2> lcd;
36 // LCD4884 lcd;
37 // LCD_Keypad lcd;
38 
39 void setup()
40 {
41  // Initiate the lcd display
42  lcd.begin();
43 }
44 
45 void loop()
46 {
47  // Print a classical greeting
48  lcd.print(lcd.WIDTH > 8 ? F("Hello World") : F("HELLO"));
49  delay(2000);
51 
52  // Print a full line
53  for (int i = 0; i < lcd.WIDTH; i++)
54  lcd.print((char) ('A' + i));
55  delay(2000);
56 
57  // Print backspace and delay show the effect
58  for (int i = 0; i < lcd.WIDTH; i++) {
59  lcd.print('\b');
60  delay(200);
61  }
63 
64  // Print integer and floating point number
65  lcd.print(-10);
66  lcd.print(F(" C"));
67  if (lcd.HEIGHT > 1) {
68  lcd.cursor_set(0, 1);
69  lcd.print(42.5);
70  lcd.print(F(" %RH"));
71  }
72  else {
73  delay(2000);
75  lcd.print(42.5);
76  lcd.print(F(" H"));
77  }
78  delay(2000);
80 
81  // Print integer in binary
82  uint16_t upper = (1 << lcd.WIDTH) - 1;
83  uint16_t lower = (1 << (lcd.WIDTH - 1));
84  lower = (upper - lower) < 1000 ? lower : upper - 1000;
85  for (uint16_t i = upper; i > lower; i--) {
86  lcd.cursor_home();
87  lcd.print(i, BIN);
88  delay(10);
89  }
91 
92  // Print floating pointer number
93  float value = 3.14159265359;
94  for (int i = 0; i < 1000; i++) {
95  lcd.cursor_home();
96  lcd.print(value, 7);
97  value += 0.000001;
98  delay(10);
99  }
100  lcd.display_clear();
101 }
virtual bool begin()
Definition: HD44780.h:132
void loop()
Definition: Demo.ino:45
Hardware::TWI twi(100000UL)
virtual void display_clear()
Definition: HD44780.h:212
virtual void cursor_set(uint8_t x, uint8_t y)
Definition: HD44780.h:245
const uint8_t HEIGHT
Definition: HD44780.h:106
HD44780 lcd(io)
void setup()
Definition: Demo.ino:39
LCD::GY_IICLCD io(twi)
const uint8_t WIDTH
Definition: HD44780.h:103
virtual void cursor_home()
Definition: HD44780.h:259