HelloWorld.ino 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. LiquidCrystal Library - Hello World
  3. Demonstrates the use a 16x2 LCD display. The LiquidCrystal
  4. library works with all LCD displays that are compatible with the
  5. Hitachi HD44780 driver. There are many of them out there, and you
  6. can usually tell them by the 16-pin interface.
  7. This sketch prints "Hello World!" to the LCD
  8. and shows the time.
  9. The circuit:
  10. * LCD RS pin to digital pin 12
  11. * LCD Enable pin to digital pin 11
  12. * LCD D4 pin to digital pin 5
  13. * LCD D5 pin to digital pin 4
  14. * LCD D6 pin to digital pin 3
  15. * LCD D7 pin to digital pin 2
  16. * LCD R/W pin to ground
  17. * LCD VSS pin to ground
  18. * LCD VCC pin to 5V
  19. * 10K resistor:
  20. * ends to +5V and ground
  21. * wiper to LCD VO pin (pin 3)
  22. Library originally added 18 Apr 2008
  23. by David A. Mellis
  24. library modified 5 Jul 2009
  25. by Limor Fried (http://www.ladyada.net)
  26. example added 9 Jul 2009
  27. by Tom Igoe
  28. modified 22 Nov 2010
  29. by Tom Igoe
  30. modified 7 Nov 2016
  31. by Arturo Guadalupi
  32. This example code is in the public domain.
  33. http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld
  34. */
  35. // include the library code:
  36. #include <LiquidCrystal.h>
  37. // initialize the library by associating any needed LCD interface pin
  38. // with the arduino pin number it is connected to
  39. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  40. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  41. void setup() {
  42. // set up the LCD's number of columns and rows:
  43. lcd.begin(16, 2);
  44. // Print a message to the LCD.
  45. lcd.print("hello, world!");
  46. }
  47. void loop() {
  48. // set the cursor to column 0, line 1
  49. // (note: line 1 is the second row, since counting begins with 0):
  50. lcd.setCursor(0, 1);
  51. // print the number of seconds since reset:
  52. lcd.print(millis() / 1000);
  53. }