This is a dotc enabled C++ module for using the 74HC595 shift register.
npm install shift_register.cpp
#require "shift_register.cpp" as ShiftRegister
ShiftRegister sr(10,11,12);
void setup() {
sr.setup();
}
uint8_t pattern = {HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW};
void loop() {
sr.writeAllPins(pattern);
sr.writePin(3, HIGH);
}
These are the pins as they corospond to the datasheet.
This simply sets the pin mode on each of the pins passed to the constructor to output so the class can write to them safely.
This takes an array of 8 values and writes them out to the output pins. It replaces whatever is already in the shift register at the time.
This takes the 0 indexed pin to write to, and the value to write to it, then it immediately writes it out. It leaves all other pins in the state they were in before writing.