setCursor.ino 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. LiquidCrystal Library - setCursor
  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 to all the positions of the LCD using the
  8. setCursor(0 method:
  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. * 10K resistor:
  18. * ends to +5V and ground
  19. * wiper to LCD VO pin (pin 3)
  20. Library originally added 18 Apr 2008
  21. by David A. Mellis
  22. library modified 5 Jul 2009
  23. by Limor Fried (http://www.ladyada.net)
  24. example added 9 Jul 2009
  25. by Tom Igoe
  26. modified 22 Nov 2010
  27. by Tom Igoe
  28. This example code is in the public domain.
  29. http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor
  30. */
  31. // include the library code:
  32. #include <LiquidCrystal.h>
  33. // these constants won't change. But you can change the size of
  34. // your LCD using them:
  35. const int numRows = 2;
  36. const int numCols = 16;
  37. // initialize the library with the numbers of the interface pins
  38. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  39. void setup() {
  40. // set up the LCD's number of columns and rows:
  41. lcd.begin(numCols, numRows);
  42. }
  43. void loop() {
  44. // loop from ASCII 'a' to ASCII 'z':
  45. for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
  46. // loop over the columns:
  47. for (int thisCol = 0; thisCol < numRows; thisCol++) {
  48. // loop over the rows:
  49. for (int thisRow = 0; thisRow < numCols; thisRow++) {
  50. // set the cursor position:
  51. lcd.setCursor(thisCol, thisRow);
  52. // print the letter:
  53. lcd.write(thisLetter);
  54. delay(200);
  55. }
  56. }
  57. }
  58. }