Guest User

Untitled

a guest
Mar 12th, 2016
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Pin connected to latch pin (ST_CP) of 74HC595 PIN 12
  3. int latchPin = 10;
  4. //Pin connected to clock pin (SH_CP) of 74HC595 PIN 11
  5. int clockPin = 11;
  6. ///Pin connected to Data in (DS) of 74HC595 PIN 14
  7. int dataPin = 12;
  8.  
  9. int load = 7; //connects load to pin 1 74hc165
  10. int clockEnablePin = 4; //connects to clock enable pin 15 74hc165
  11. int dataIn = 5; //connects to the data pin 7 74hc165
  12. int clockIn = 6; //connects to the clock pin 2 74hc165
  13.  
  14.  
  15. void setup() {
  16.  
  17. Serial.begin(9600);
  18.  
  19. //74HC165
  20. pinMode(load, OUTPUT); // pin 1 connect to pin 7 on arduino
  21. pinMode(dataIn, INPUT); // pin 7 connect to pin 5 on arduino
  22. pinMode(clockIn, OUTPUT); // pin 2 connect to pin 6 on arduino
  23. pinMode(clockEnablePin, OUTPUT); // pin 15 connect to pin 4 on arduino
  24.  
  25.  
  26. //74HC595
  27. pinMode(latchPin, OUTPUT); // pin 12 connect to pin 10 on arduino
  28. pinMode(dataPin, OUTPUT); // pin 14 connect to pin 12 on arduino
  29. pinMode(clockPin, OUTPUT); // pin 11 connect to pin 11 on arduino
  30.  
  31. }
  32.  
  33.  
  34. void loop() {
  35.  
  36. digitalWrite(load,LOW);
  37. delayMicroseconds (10);
  38. digitalWrite(load,HIGH);
  39. delayMicroseconds (10);
  40.  
  41. digitalWrite(clockIn, HIGH);
  42. digitalWrite(clockEnablePin, LOW);
  43. byte incoming = shiftIn(dataIn, clockIn, LSBFIRST);
  44. digitalWrite(clockEnablePin,HIGH);
  45.  
  46. digitalWrite(latchPin, LOW);
  47. shiftOut(dataPin, clockPin, LSBFIRST, incoming); //1-8
  48. digitalWrite(latchPin, HIGH);
  49. delay(50);
  50.  
  51. Serial.print("Pin States:\r\n");
  52. Serial.println(incoming, BIN);
  53. delay(200);
  54. }
RAW Paste Data