From 0974decf81e462cb3f2b0855fbf4f30965ae5a4b Mon Sep 17 00:00:00 2001 From: aavestan Date: Sat, 15 Sep 2018 12:53:29 +0430 Subject: [PATCH] Create AutoFindAddress.ino Auto detect LCD address between 0x3F or 0x27 --- examples/AutoFindAddress/AutoFindAddress.ino | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/AutoFindAddress/AutoFindAddress.ino diff --git a/examples/AutoFindAddress/AutoFindAddress.ino b/examples/AutoFindAddress/AutoFindAddress.ino new file mode 100644 index 0000000..7c72d8d --- /dev/null +++ b/examples/AutoFindAddress/AutoFindAddress.ino @@ -0,0 +1,28 @@ +#include +#include + +// Auto detect LCD address between 0x3F or 0x27 +byte autolcdaddr(){ +Wire.begin(); +Wire.beginTransmission(0x27); +return Wire.endTransmission()? 0x3F:0x27; +} + + +// Set the LCD for a 16 chars and 2 line display +LiquidCrystal_I2C lcd(autolcdaddr(), 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... +}