Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. /* YourDuino.com Example Software Sketch
  2. 16 character 2 line I2C Display
  3. Backpack Interface labelled "A0 A1 A2" at lower right.
  4. ..and
  5. Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
  6. MOST use address 0x27, a FEW use 0x3F
  7. terry@yourduino.com */
  8.  
  9. /*-----( Import needed libraries )-----*/
  10. #include <Wire.h> // Comes with Arduino IDE
  11. // Get the LCD I2C Library here:
  12. // https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
  13. // Move any other LCD libraries to another folder or delete them
  14. // See Library "Docs" folder for possible commands etc.
  15. #include <LiquidCrystal_I2C.h>
  16.  
  17. /*-----( Declare Constants )-----*/
  18. /*-----( Declare objects )-----*/
  19. // set the LCD address to 0x27 for a 16 chars 2 line display
  20. // A FEW use address 0x3F
  21. // Set the pins on the I2C chip used for LCD connections:
  22. // addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
  23. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
  24.  
  25. /*-----( Declare Variables )-----*/
  26. //NONE
  27.  
  28. void setup() /*----( SETUP: RUNS ONCE )----*/
  29. {
  30. Serial.begin(9600); // Used to type in characters
  31.  
  32. lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight
  33.  
  34. // ------- Quick 3 blinks of backlight -------------
  35. lcd.backlight(); // finish with backlight on
  36. delay(8000);
  37.  
  38. //-------- Write characters on the display ------------------
  39. // NOTE: Cursor Position: (CHAR, LINE) start at 0
  40. lcd.setCursor(0,0); //Start at character 4 on line 0
  41. lcd.print("Hello, world!");
  42. delay(1000);
  43. lcd.setCursor(0,1);
  44. lcd.print("HI!YourDuino.com");
  45. delay(8000);
  46.  
  47. // Wait and then tell user they can start the Serial Monitor and type in characters to
  48. // Display. (Set Serial Monitor option to "No Line Ending")
  49. lcd.clear();
  50. lcd.setCursor(0,0); //Start at character 0 on line 0
  51. lcd.print("Use Serial Mon");
  52. lcd.setCursor(0,1);
  53. lcd.print("Type to display");
  54.  
  55.  
  56. }/*--(end setup )---*/
  57.  
  58.  
  59. void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
  60. {
  61. {
  62. // when characters arrive over the serial port...
  63. if (Serial.available()) {
  64. // wait a bit for the entire message to arrive
  65. delay(100);
  66. // clear the screen
  67. lcd.clear();
  68. // read all the available characters
  69. while (Serial.available() > 0) {
  70. // display each character to the LCD
  71. lcd.write(Serial.read());
  72. }
  73. }
  74. }
  75.  
  76. }/* --(end main loop )-- */
  77.  
  78.  
  79. /* ( THE END ) */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement