Advertisement
mongerr

16 LED with register

Jun 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. int latchPin = 9;
  2. int dataPin = 8;
  3. int clockPin = 10;
  4. int dato = 0;
  5. int waitFor = 200;
  6.  
  7. int first = 0;
  8. int second = 0;
  9.  
  10. void setup() {
  11. pinMode (dataPin, OUTPUT);
  12. pinMode (clockPin, OUTPUT);
  13. pinMode (latchPin, OUTPUT);
  14. }
  15.  
  16. void loop()
  17. {
  18. lightLeds (0b00000000, 0b00000000);
  19.  
  20. lightLeds (0b00000001, 0b00000000);
  21. lightLeds (0b00000011, 0b00000000);
  22. lightLeds (0b00000111, 0b00000000);
  23. lightLeds (0b00001111, 0b00000000);
  24.  
  25. lightLeds (0b00011111, 0b00000000);
  26. lightLeds (0b00111111, 0b00000000);
  27. lightLeds (0b01111111, 0b00000000);
  28. lightLeds (0b11111111, 0b00000000);
  29.  
  30. lightLeds (0b11111111, 0b00000001);
  31. lightLeds (0b11111111, 0b00000011);
  32. lightLeds (0b11111111, 0b00000111);
  33. lightLeds (0b11111111, 0b00001111);
  34.  
  35. lightLeds (0b11111111, 0b00011111);
  36. lightLeds (0b11111111, 0b00111111);
  37. lightLeds (0b11111111, 0b01111111);
  38. lightLeds (0b11111111, 0b11111111);
  39.  
  40. //
  41.  
  42. lightLeds (0b11111111, 0b11111111);
  43. lightLeds (0b11111111, 0b01111111);
  44. lightLeds (0b11111111, 0b00111111);
  45. lightLeds (0b11111111, 0b00011111);
  46.  
  47. lightLeds (0b11111111, 0b00001111);
  48. lightLeds (0b11111111, 0b00000111);
  49. lightLeds (0b11111111, 0b00000011);
  50. lightLeds (0b11111111, 0b00000001);
  51.  
  52. lightLeds (0b11111111, 0b00000000);
  53. lightLeds (0b01111111, 0b00000000);
  54. lightLeds (0b00111111, 0b00000000);
  55. lightLeds (0b00011111, 0b00000000);
  56.  
  57. lightLeds (0b00001111, 0b00000000);
  58. lightLeds (0b00000111, 0b00000000);
  59. lightLeds (0b00000011, 0b00000000);
  60. lightLeds (0b00000001, 0b00000000);
  61.  
  62. lightLeds (0b00000000, 0b00000000);
  63.  
  64. }
  65.  
  66. void lightLeds (int second, int first)
  67. {
  68. digitalWrite (latchPin, LOW);
  69. shiftOut (dataPin, clockPin, LSBFIRST, first);
  70. shiftOut (dataPin, clockPin, LSBFIRST, second);
  71. digitalWrite (latchPin, HIGH);
  72. delay (waitFor);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement