PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TextDirection.ino 1.9KB

3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. LiquidCrystal Library - TextDirection
  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 demonstrates how to use leftToRight() and rightToLeft()
  8. to move the cursor.
  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. modified 7 Nov 2016
  29. by Arturo Guadalupi
  30. This example code is in the public domain.
  31. http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection
  32. */
  33. // include the library code:
  34. #include <LiquidCrystal.h>
  35. // initialize the library by associating any needed LCD interface pin
  36. // with the arduino pin number it is connected to
  37. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  38. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  39. int thisChar = 'a';
  40. void setup() {
  41. // set up the LCD's number of columns and rows:
  42. lcd.begin(16, 2);
  43. // turn on the cursor:
  44. lcd.cursor();
  45. }
  46. void loop() {
  47. // reverse directions at 'm':
  48. if (thisChar == 'm') {
  49. // go right for the next letter
  50. lcd.rightToLeft();
  51. }
  52. // reverse again at 's':
  53. if (thisChar == 's') {
  54. // go left for the next letter
  55. lcd.leftToRight();
  56. }
  57. // reset at 'z':
  58. if (thisChar > 'z') {
  59. // go to (0,0):
  60. lcd.home();
  61. // start again at 0
  62. thisChar = 'a';
  63. }
  64. // print the character
  65. lcd.write(thisChar);
  66. // wait a second:
  67. delay(1000);
  68. // increment the letter:
  69. thisChar++;
  70. }