PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LCDemo7Segment.ino 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //We always have to include the library
  2. #include "LedControl.h"
  3. /*
  4. Now we need a LedControl to work with.
  5. ***** These pin numbers will probably not work with your hardware *****
  6. pin 12 is connected to the DataIn
  7. pin 11 is connected to the CLK
  8. pin 10 is connected to LOAD
  9. We have only a single MAX72XX.
  10. */
  11. LedControl lc=LedControl(12,11,10,1);
  12. /* we always wait a bit between updates of the display */
  13. unsigned long delaytime=250;
  14. void setup() {
  15. /*
  16. The MAX72XX is in power-saving mode on startup,
  17. we have to do a wakeup call
  18. */
  19. lc.shutdown(0,false);
  20. /* Set the brightness to a medium values */
  21. lc.setIntensity(0,8);
  22. /* and clear the display */
  23. lc.clearDisplay(0);
  24. }
  25. /*
  26. This method will display the characters for the
  27. word "Arduino" one after the other on digit 0.
  28. */
  29. void writeArduinoOn7Segment() {
  30. lc.setChar(0,0,'a',false);
  31. delay(delaytime);
  32. lc.setRow(0,0,0x05);
  33. delay(delaytime);
  34. lc.setChar(0,0,'d',false);
  35. delay(delaytime);
  36. lc.setRow(0,0,0x1c);
  37. delay(delaytime);
  38. lc.setRow(0,0,B00010000);
  39. delay(delaytime);
  40. lc.setRow(0,0,0x15);
  41. delay(delaytime);
  42. lc.setRow(0,0,0x1D);
  43. delay(delaytime);
  44. lc.clearDisplay(0);
  45. delay(delaytime);
  46. }
  47. /*
  48. This method will scroll all the hexa-decimal
  49. numbers and letters on the display. You will need at least
  50. four 7-Segment digits. otherwise it won't really look that good.
  51. */
  52. void scrollDigits() {
  53. for(int i=0;i<13;i++) {
  54. lc.setDigit(0,3,i,false);
  55. lc.setDigit(0,2,i+1,false);
  56. lc.setDigit(0,1,i+2,false);
  57. lc.setDigit(0,0,i+3,false);
  58. delay(delaytime);
  59. }
  60. lc.clearDisplay(0);
  61. delay(delaytime);
  62. }
  63. void loop() {
  64. writeArduinoOn7Segment();
  65. scrollDigits();
  66. }