Advertisement
ananias_hayes12

Shift Register Forwards and Backwards

Jun 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. /* Void Loop Oder of LEDs
  2. * ANANIAS HAYES
  3. */
  4.  
  5. const int SER = 8;
  6. const int LATCH = 9;
  7. const int CLK = 10;
  8. int lights [15] = { 1, 2, 4, 8, 16, 32, 64, 128, 64, 32, 16, 8, 4, 2, 1};
  9. int BAR [16] = {1, 3, 7, 15, 31, 63, 127, 255, };
  10.  
  11. void setup()
  12. {
  13. pinMode (SER, OUTPUT);
  14. pinMode (LATCH, OUTPUT);
  15. pinMode (CLK, OUTPUT);
  16. }
  17.  
  18. void loop()
  19. {
  20. for (int i = 0; i < 15; i++)
  21. {
  22. digitalWrite (LATCH, LOW);
  23. shiftOut (SER, CLK, MSBFIRST, lights [i]);
  24. digitalWrite (LATCH, HIGH);
  25. delay (100);
  26. }
  27. for (int j= 0; j < 16; j++)
  28. {
  29. digitalWrite (LATCH, LOW);
  30. shiftOut (SER, CLK, MSBFIRST, BAR[j]);
  31. digitalWrite (LATCH, HIGH);
  32. delay (100);
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement