Guest User

Untitled

a guest
Jul 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. //**************************************************************//
  2. // Name : shiftOutCode, Hello World: The Remake //
  3. // : From BYTE to INT and back again //
  4. //****************************************************************
  5.  
  6. // Pin connected to ST_CP of 74HC595
  7. int latchPin = 8;
  8. // Pin connected to SH_CP of 74HC595
  9. int clockPin = 12;
  10. // Pin connected to DS of 74HC595
  11. int dataPin = 11;
  12.  
  13. void setup() {
  14. // set pins to output because they are addressed in the main loop
  15. pinMode(latchPin, OUTPUT);
  16. pinMode(clockPin, OUTPUT);
  17. pinMode(dataPin, OUTPUT);
  18. }
  19.  
  20. void loop() {
  21. apply( B11111111, B00000000, 500 );
  22. apply( B00000000, B11111111, 500 );
  23. }
  24.  
  25. // to apply a value to the chip
  26. void apply( byte first_pin_val, byte second_pin_val, int wait ) {
  27. digitalWrite(latchPin, LOW); // first turn off the latch
  28. shiftOut( dataPin, clockPin, LSBFIRST, int(first_pin_val) );
  29. shiftOut( dataPin, clockPin, LSBFIRST, int(second_pin_val) );
  30. digitalWrite(latchPin, HIGH); // turn on the latch, to prevent more writing.
  31.  
  32. delay( wait ); // and wait until we start again.
  33. }
Add Comment
Please, Sign In to add comment