_07_LCD1602.ino 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /***********************************************************
  2. File name: 07_LCD1602.ino
  3. Description: LCD1602 display a string "Hello Geeks!" scrolling,
  4. then display “Adeept” and “www.adeept.com” static.
  5. Website: www.adeept.com
  6. E-mail: support@adeept.com
  7. Author: Tom
  8. Date: 2015/05/02
  9. ***********************************************************/
  10. #include <LiquidCrystal.h>
  11. char array1[]=" Adeept "; //the string to print on the LCD
  12. char array2[]=" hello geeks! "; //the string to print on the LCD
  13. char array3[]=" www.adeept.com "; //the string to print on the LCD
  14. int tim = 250; //the value of delay time
  15. // initialize the library with the numbers of the interface pins
  16. LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
  17. void setup()
  18. {
  19. lcd.begin(16, 2); // set up the LCD's number of columns and rows:
  20. }
  21. void loop()
  22. {
  23. lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner
  24. lcd.setCursor(15,0); // set the cursor to column 15, line 1
  25. for (int positionCounter2 = 0; positionCounter2 < 30; positionCounter2++)
  26. {
  27. lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.
  28. lcd.print(array2[positionCounter2]); // Print a message to the LCD.
  29. delay(tim); //wait for 250 microseconds
  30. }
  31. lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.
  32. lcd.setCursor(0,0); // set the cursor to column 15, line 0
  33. for (int positionCounter1 = 0; positionCounter1 < 16; positionCounter1++)
  34. {
  35. lcd.print(array1[positionCounter1]); // Print a message to the LCD.
  36. delay(tim); //wait for 250 microseconds
  37. }
  38. lcd.setCursor(0,1); // set the cursor to column 15, line 1
  39. for (int positionCounter3 = 0; positionCounter3 < 16; positionCounter3++)
  40. {
  41. lcd.print(array3[positionCounter3]); // Print a message to the LCD.
  42. delay(tim); //wait for 250 microseconds
  43. }
  44. }