/*
https://thesolaruniverse.wordpress.com/2019/11/16/two-ways-to-control-a-ten-segment-led-bar-with-an-arduino/
https://arduino.stackexchange.com/questions/17092/multiple-shift-registers-16-bit-numbers
https://create.arduino.cc/projecthub/embeddedlab786/how-to-control-16-leds-with-74hc595-shift-register-423a9d
https://github.com/Simsso/ShiftRegister74HC595/blob/master/examples/example/example.ino
*/
#include <ShiftRegister74HC595.h>
const int latchPin = 10;
// SH_CP pin 11
const int clockPin = 11;
// DS pin 14
const int dataPin = 12;
const int countLed = 16;
// parameters: <number of shift registers> (data pin, clock pin, latch pin)
ShiftRegister74HC595<2> sr(dataPin, clockPin, latchPin);
void setup (){
/*
pinMode (clockPin, OUTPUT);
pinMode (latchPin, OUTPUT);
pinMode (dataPin, OUTPUT);
*/
}
void loop (){
// setting all pins at the same time to either HIGH or LOW
sr.setAllHigh(); // set all pins HIGH
delay(500);
sr.setAllLow(); // set all pins LOW
delay(500);
// setting single pins
for (int i = 0; i < countLed; i++) {
sr.set(i, HIGH); // set single pin HIGH
delay(50);
}
sr.setAllLow(); // set all pins LOW
delay(500);
// set pins without immediate update
sr.setNoUpdate(0, HIGH);
sr.setNoUpdate(4, HIGH);
sr.setNoUpdate(8, HIGH);
sr.setNoUpdate(12, HIGH);
// at this point of time, pin 0 and 1 did not change yet
sr.updateRegisters(); // update the pins to the set values
delay(1000);
}