PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

87 Zeilen
1.9KB

  1. /*
  2. LiquidCrystalFast Library - TextDirection
  3. Demonstrates the use a 16x2 LCD display. The LiquidCrystalFast
  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 WR pin to digital pin 10
  12. * LCD Enable pin to digital pin 11
  13. * LCD D4 pin to digital pin 5
  14. * LCD D5 pin to digital pin 4
  15. * LCD D6 pin to digital pin 3
  16. * LCD D7 pin to digital pin 2
  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 25 July 2009
  27. by David A. Mellis
  28. http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html
  29. http://www.arduino.cc/en/Tutorial/LiquidCrystal
  30. */
  31. // include the library code:
  32. #include <LiquidCrystalFast.h>
  33. // initialize the library with the numbers of the interface pins
  34. LiquidCrystalFast lcd(12, 10, 11, 5, 4, 3, 2);
  35. // LCD pins: RS RW EN D4 D5 D6 D7
  36. int thisChar = 'a';
  37. void setup() {
  38. // set up the LCD's number of rows and columns:
  39. lcd.begin(16, 2);
  40. // turn on the cursor:
  41. lcd.cursor();
  42. Serial.begin(9600);
  43. }
  44. void loop() {
  45. // reverse directions at 'm':
  46. if (thisChar == 'm') {
  47. // go right for the next letter
  48. lcd.rightToLeft();
  49. }
  50. // reverse again at 's':
  51. if (thisChar == 's') {
  52. // go left for the next letter
  53. lcd.leftToRight();
  54. }
  55. // reset at 'z':
  56. if (thisChar > 'z') {
  57. // go to (0,0):
  58. lcd.home();
  59. // start again at 0
  60. thisChar = 'a';
  61. }
  62. // print the character
  63. lcd.write(thisChar);
  64. // wait a second:
  65. delay(1000);
  66. // increment the letter:
  67. thisChar++;
  68. }