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

LCDemoCascadedDevices.ino 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. ***** Please set the number of devices you have *****
  10. But the maximum default of 8 MAX72XX wil also work.
  11. */
  12. LedControl lc=LedControl(12,11,10,8);
  13. /* we always wait a bit between updates of the display */
  14. unsigned long delaytime=500;
  15. /*
  16. This time we have more than one device.
  17. But all of them have to be initialized
  18. individually.
  19. */
  20. void setup() {
  21. //we have already set the number of devices when we created the LedControl
  22. int devices=lc.getDeviceCount();
  23. //we have to init all devices in a loop
  24. for(int address=0;address<devices;address++) {
  25. /*The MAX72XX is in power-saving mode on startup*/
  26. lc.shutdown(address,false);
  27. /* Set the brightness to a medium values */
  28. lc.setIntensity(address,8);
  29. /* and clear the display */
  30. lc.clearDisplay(address);
  31. }
  32. }
  33. void loop() {
  34. //read the number cascaded devices
  35. int devices=lc.getDeviceCount();
  36. //we have to init all devices in a loop
  37. for(int row=0;row<8;row++) {
  38. for(int col=0;col<8;col++) {
  39. for(int address=0;address<devices;address++) {
  40. delay(delaytime);
  41. lc.setLed(address,row,col,true);
  42. delay(delaytime);
  43. lc.setLed(address,row,col,false);
  44. }
  45. }
  46. }
  47. }