add Liquid Crystal I2C Library
This commit is contained in:
parent
1373123656
commit
c4de182223
8 changed files with 628 additions and 0 deletions
|
@ -0,0 +1,32 @@
|
|||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// Set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// initialize the LCD
|
||||
lcd.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
bool blinking = true;
|
||||
lcd.cursor();
|
||||
|
||||
while (1) {
|
||||
if (blinking) {
|
||||
lcd.clear();
|
||||
lcd.print("No cursor blink");
|
||||
lcd.noBlink();
|
||||
blinking = false;
|
||||
} else {
|
||||
lcd.clear();
|
||||
lcd.print("Cursor blink");
|
||||
lcd.blink();
|
||||
blinking = true;
|
||||
}
|
||||
delay(4000);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
uint8_t bell[8] = {0x4, 0xe, 0xe, 0xe, 0x1f, 0x0, 0x4};
|
||||
uint8_t note[8] = {0x2, 0x3, 0x2, 0xe, 0x1e, 0xc, 0x0};
|
||||
uint8_t clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0};
|
||||
uint8_t heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};
|
||||
uint8_t duck[8] = {0x0, 0xc, 0x1d, 0xf, 0xf, 0x6, 0x0};
|
||||
uint8_t check[8] = {0x0, 0x1 ,0x3, 0x16, 0x1c, 0x8, 0x0};
|
||||
uint8_t cross[8] = {0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0};
|
||||
uint8_t retarrow[8] = { 0x1, 0x1, 0x5, 0x9, 0x1f, 0x8, 0x4};
|
||||
|
||||
// Set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.begin();
|
||||
lcd.backlight();
|
||||
|
||||
lcd.createChar(0, bell);
|
||||
lcd.createChar(1, note);
|
||||
lcd.createChar(2, clock);
|
||||
lcd.createChar(3, heart);
|
||||
lcd.createChar(4, duck);
|
||||
lcd.createChar(5, check);
|
||||
lcd.createChar(6, cross);
|
||||
lcd.createChar(7, retarrow);
|
||||
lcd.home();
|
||||
|
||||
lcd.print("Hello world...");
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(" i ");
|
||||
lcd.write(3);
|
||||
lcd.print(" arduinos!");
|
||||
delay(5000);
|
||||
displayKeyCodes();
|
||||
}
|
||||
|
||||
// display all keycodes
|
||||
void displayKeyCodes(void) {
|
||||
uint8_t i = 0;
|
||||
|
||||
while (1) {
|
||||
lcd.clear();
|
||||
lcd.print("Codes 0x");
|
||||
lcd.print(i, HEX);
|
||||
lcd.print("-0x");
|
||||
lcd.print(i + 16, HEX);
|
||||
lcd.setCursor(0, 1);
|
||||
|
||||
for (int j = 0; j < 16; j++) {
|
||||
lcd.write(i + j);
|
||||
}
|
||||
i += 16;
|
||||
|
||||
delay(4000);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Do nothing here...
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// Set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// initialize the LCD
|
||||
lcd.begin();
|
||||
|
||||
// Turn on the blacklight and print a message.
|
||||
lcd.backlight();
|
||||
lcd.print("Hello, world!");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Do nothing here...
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
|
||||
* an attached LCD.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// Set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.begin();
|
||||
lcd.backlight();
|
||||
|
||||
// Initialize the serial port at a speed of 9600 baud
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// If characters arrived over the serial port...
|
||||
if (Serial.available()) {
|
||||
// Wait a bit for the entire message to arrive
|
||||
delay(100);
|
||||
// Clear the screen
|
||||
lcd.clear();
|
||||
|
||||
// Write all characters received with the serial port to the LCD.
|
||||
while (Serial.available() > 0) {
|
||||
lcd.write(Serial.read());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue