Advertisement
CrhisDLM

LAb 7 Arduino

Jul 7th, 2025 (edited)
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. //Lab 7
  2. //Crhistian David Lucumi
  3. //09/11/2014
  4.  
  5. //Pin connected to ST_CP of 74HC595
  6. int latchPin = 8;
  7. //Pin connected to SH_CP of 74HC595
  8. int clockPin = 12;
  9. ////Pin connected to DS of 74HC595
  10. int dataPin = 11;
  11.  
  12.  
  13.  
  14. void setup() {
  15.   //set pins to output so you can control the shift register
  16.     Serial.begin(9600);
  17.   pinMode(latchPin, OUTPUT);
  18.   pinMode(clockPin, OUTPUT);
  19.   pinMode(dataPin, OUTPUT);
  20. }
  21.  
  22. void loop() {
  23.   // count from 0 to 255 and display the number
  24.   // on the LEDs
  25.    if (Serial.available()>0){
  26.     Serial.parseInt();
  27.     Serial.println(Serial.parseInt());
  28.     // take the latchPin low so
  29.     // the LEDs don't change while you're sending in bits:
  30.     digitalWrite(latchPin, LOW);
  31.     // shift out the bits:
  32.     shiftOut(dataPin, clockPin, MSBFIRST, Serial.parseInt());  
  33.  
  34.     //take the latch pin high so the LEDs will light up:
  35.     digitalWrite(latchPin, HIGH);
  36.     // pause before next value:
  37.     delay(500);
  38.   }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement