Advertisement
DuboisP

noel_led_multiplexer

Dec 22nd, 2024 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | Source Code | 0 0
  1. #include <ShiftRegister74HC595.h>
  2.  
  3. ShiftRegister74HC595<4>* sr;
  4.  
  5. int t23[] = { 140, 300, 120, 600, 400 };
  6. int t0[] = { 150, 170, 160, 800, 190 }; // n'est pas utilisé ?
  7.  
  8. uint8_t p23[][4] =
  9.  {{B00000000,B00000000,B00000000,B00000000},
  10. {B10000000,B00010000,B10000000,B10000000},
  11. {B11000000,B00110000,B11000000,B11000000},
  12. {B11100000,B01110000,B11100000,B11100000},
  13. {B11110000,B11110000,B11110000,B11110000},
  14. {B11111000,B11110001,B11110000,B11111000},
  15. {B11111100,B11110011,B11111100,B11111100},
  16. {B11111110,B11110111,B11111110,B11111110},
  17. {B11111111,B11111111,B11111111,B11111111},
  18. {B00000000,B00000000,B00000000,B00000000},
  19. {B11111111,B00000000,B00000000,B00000000},
  20. {B11111111,B11111111,B00000000,B00000000},
  21. {B11111111,B11111111,B11111111,B00000001},
  22. {B11111111,B11111111,B11111111,B11111111},
  23. {B00000000,B00000000,B00000000,B00000000},
  24. {B11111111,B11111111,B11111111,B11111111},
  25. {B11111110,B11110111,B11111110,B11111110},
  26. {B11111100,B11110011,B11111100,B11111100},
  27. {B11111000,B11110001,B11110000,B11111000},
  28. {B11110000,B11110000,B11110000,B11110000},
  29. {B11100000,B01110000,B11100000,B11100000},
  30. {B11100000,B01110000,B11100000,B11100000},
  31. {B11000000,B00110000,B11000000,B11000000},
  32. {B10000000,B00010000,B10000000,B10000000},};
  33.  
  34. int nt23, np23;
  35.  
  36.  
  37. void setAndDelay(ShiftRegister74HC595<4>& sr, uint8_t pattern[], int delayTime) {
  38.  
  39.   sr.setAll(pattern);
  40.   delay(delayTime);
  41. }
  42.  
  43. void setup() {
  44.   sr = new ShiftRegister74HC595<4>(4, 2, 3);
  45.   np23 = sizeof(p23) / sizeof(p23[0]);    //
  46.   nt23 = sizeof(t23) / sizeof(t23[0]);    // ou nt23 = 5;
  47. }
  48.    
  49. void loop() {
  50.  
  51.   for (int j = 0; j < nt23; ++j) {
  52.     for (int i = 0; i < np23; ++i) {
  53.       setAndDelay(*sr, p23[i], t23[j]);
  54.     }
  55.   }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement