/*
74HC595 Arduino Shift Register example for Wokwi
Copyright (C) 2021, Uri Shaked
explanation to control 8 leds we require 9 conections one is comman cathod and another 8 anode but here
ic 74hc595 uses three pins from micro controller and alternatly glow red and green led .this is called multiplexing or charliplexing
ic is known as shift rtagister.
you can add one more ic to connect 8 more leds but pin 2,3,4 be connected to parrallel
https://lastminuteengineers.com/74hc595-shift-register-arduino-tutorial/#:~:text=The%20first%20one%20is%20called%20the
License: MIT.
*/
const int dataPin = 2; /* DS */
const int clockPin = 3; /* SHCP */
const int latchPin = 4; /* STCP */
void setup() {
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
}
int pattern = 0b10101010;
void loop() {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, pattern);
digitalWrite(latchPin, HIGH);
delay(2000);
pattern = ~pattern; // Invert the pattern
}