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.

Scroll.pde 2.4KB

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. LiquidCrystalFast Library - scrollDisplayLeft() and scrollDisplayRight()
  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 prints "Hello World!" to the LCD and uses the
  8. scrollDisplayLeft() and scrollDisplayRight() methods to scroll
  9. the text.
  10. The circuit:
  11. * LCD RS pin to digital pin 12
  12. * LCD WR pin to digital pin 10
  13. * LCD Enable pin to digital pin 11
  14. * LCD D4 pin to digital pin 5
  15. * LCD D5 pin to digital pin 4
  16. * LCD D6 pin to digital pin 3
  17. * LCD D7 pin to digital pin 2
  18. * 10K resistor:
  19. * ends to +5V and ground
  20. * wiper to LCD VO pin (pin 3)
  21. Library originally added 18 Apr 2008
  22. by David A. Mellis
  23. library modified 5 Jul 2009
  24. by Limor Fried (http://www.ladyada.net)
  25. example added 9 Jul 2009
  26. by Tom Igoe
  27. modified 25 July 2009
  28. by David A. Mellis
  29. http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html
  30. http://www.arduino.cc/en/Tutorial/LiquidCrystal
  31. */
  32. // include the library code:
  33. #include <LiquidCrystalFast.h>
  34. // initialize the library with the numbers of the interface pins
  35. LiquidCrystalFast lcd(12, 10, 11, 5, 4, 3, 2);
  36. // LCD pins: RS RW EN D4 D5 D6 D7
  37. void setup() {
  38. // set up the LCD's number of rows and columns:
  39. lcd.begin(16, 2);
  40. //lcd.setCursor(0,7);
  41. // Print a message to the LCD.
  42. lcd.print("hello, world!");
  43. delay(1000);
  44. }
  45. void loop() {
  46. // scroll 13 positions (string length) to the left
  47. // to move it offscreen left:
  48. for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
  49. // scroll one position left:
  50. lcd.scrollDisplayLeft();
  51. // wait a bit:
  52. delay(150);
  53. }
  54. // scroll 29 positions (string length + display length) to the right
  55. // to move it offscreen right:
  56. for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
  57. // scroll one position right:
  58. lcd.scrollDisplayRight();
  59. // wait a bit:
  60. delay(150);
  61. }
  62. // scroll 16 positions (display length + string length) to the left
  63. // to move it back to center:
  64. for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
  65. // scroll one position left:
  66. lcd.scrollDisplayLeft();
  67. // wait a bit:
  68. delay(150);
  69. }
  70. // delay at the end of the full loop:
  71. delay(1000);
  72. }