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.

53 satır
1.4KB

  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. }