weinerm21

Untitled

Jun 13th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. const int SER = 3;
  2. const int LATCH = 5;
  3. const int CLK = 4;
  4. int LedVals[9] = {0,1,2,4,8,16,32,64,128);
  5. int BacklLedVals[9] = {128,64,32,16,8,4,2,1,0};
  6. void setup()
  7. {
  8. // put your setup code here, to run once:
  9. pinMode(SER, OUTPUT);
  10. pinMode(LATCH, OUTPUT);
  11. pinMode(CLK, OUTPUT);
  12. digitalWrite(LATCH, LOW);
  13. shiftOut(SER, CLK, MSBFIRST, B11111111);
  14. digitalWrite(LATCH, HIGH);
  15. delay(200);
  16. digitalWrite(LATCH, LOW);
  17. shiftOut(SER, CLK, MSBFIRST, B00000000;
  18. digitalWrite(LATCH, HIGH);
  19. }
  20.  
  21. void loop()
  22. {
  23. // put your main code here, to run repeatedly:
  24. for(int i=0; i<8; i++)
  25. {
  26. digitalWrite(LATCH, LOW);
  27. shiftOut(SER, CLK, MSBFIRST, LedVals[i]);
  28. digitalWrite(LATCH, HIGH);
  29. delay (200);
  30. }
  31. for(int i=0; i<8; i++)
  32. {
  33. digitalWrite(LATCH, LOW);
  34. shiftOut(SER, CLK, MSBFIRST, BackLedVals[i]);
  35. digitalWrite(LATCH, HIGH);
  36. delay (200);
  37. }
  38. }
Add Comment
Please, Sign In to add comment