1. /*
  2. ** Example Arduino sketch for SainSmart I2C LCD Screen 16x2
  3. ** based on https://bitbucket.org/celem/sainsmart-i2c-lcd/src/3adf8e0d2443/sainlcdtest.ino
  4. ** by
  5. ** Edward Comer
  6. ** LICENSE: GNU General Public License, version 3 (GPL-3.0)
  7. ** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
  8. ** https://bitbucket.org/fmalpartida/new-liquidcrystal
  9. ** Modified – Ian Brennan ianbren at hotmail.com 23-10-2012 to support Tutorial posted to Arduino.cc
  10. ** Written for and tested with Arduino 1.0
  11. **
  12. ** NOTE: Tested on Arduino Uno whose I2C pins are A4==SDA, A5==SCL
  13. */
  14. #include <Wire.h>
  15. #include <LCD.h>
  16. #include <LiquidCrystal_I2C.h>
  17. #define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
  18. #define BACKLIGHT_PIN 3
  19. #define En_pin 2
  20. #define Rw_pin 1
  21. #define Rs_pin 0
  22. #define D4_pin 4
  23. #define D5_pin 5
  24. #define D6_pin 6
  25. #define D7_pin 7
  26. LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
  27. void setup()
  28. {
  29. lcd.begin (16,2);
  30. // Switch on the backlight
  31. lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  32. lcd.setBacklight(HIGH);
  33. lcd.setCursor (0,0);
  34. lcd.print("SainSmart");
  35. lcd.setCursor (0,1);
  36. lcd.print("I2C 16x2");
  37. }
  38. void loop()
  39. {
  40. }