weinerm21

Untitled

Jun 12th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /*
  2. ShiftRegister74HC595.h - Library for easy control of the 74HC595 shift register.
  3. Created by Timo Denk (www.simsso.de), Nov 2014.
  4. Additional information are available on http://shiftregister.simsso.de/
  5. Released into the public domain.
  6. */
  7.  
  8. #include <ShiftRegister74HC595.h>
  9.  
  10. // create shift register object (number of shift registers, data pin, clock pin, latch pin)
  11. ShiftRegister74HC595 sr (1, 2, 3, 4);
  12.  
  13. void setup() {
  14. }
  15.  
  16. void loop() {
  17.  
  18. sr.setAllHigh(); // set all pins HIGH
  19. delay(500);
  20.  
  21. sr.setAllLow(); // set all pins LOW
  22. delay(500);
  23.  
  24.  
  25. for (int i = 0; i < 8; i++) {
  26.  
  27. sr.set(i, HIGH); // set single pin HIGH
  28. delay(2000);
  29. }
  30.  
  31.  
  32. // set all pins at once
  33. uint8_t pinValues[] = { B10101010 };
  34. sr.setAll(pinValues);
  35. delay(5000);
  36.  
  37. // read pin (zero based)
  38. uint8_t stateOfPin5 = sr.get(5);
  39.  
  40. }
Add Comment
Please, Sign In to add comment