Shift Register Library

My goal here is to create an easy to use, OOP Based, Shift Register lib for all yall to use!

I've done some lib development before, but I really haven't seen too many libs focusing on Shift Registers. So, right now, this post is just a placeholder for the lib in the making. I am about 1/2 way through with it, I'll keep you guys posted while in dev!

Currently defined functions:

shiftRegister.begin(int, int, int); //Define pins to use for latch, clock, and data. Last int defines number of registers.
shiftRegister.setPinState(int, bool); // I'll implement error handling later for trying to set pins that dont exits (or throw any other errors)
shiftRegister.setAllLow(); //This will actually set ALL the pins to low internaly, to tie up any loose ends
shiftRegister.flush(); //Flush output to registers
shiftRegister.pwm(int); //I may take this one out if its too buggy
shiftRegister.random(); //for fun!
shiftRegister.setDedbugMode(int); //Set different debug modes to debug to the serial port for ease of... well... debugging!
The LCD code is in pre alpha even, it may take a while to get up :)
shiftRegister.setLcdMode(); //to support 3 wire LCD :)

As the code is developed and debugged further, I'll be posting more code! Stay Tuned!

Also, if you have any comments or questions, please fell free to say (this is a forum after all!)

Just throwing out a few ideas:

Well to be general purpose I would like to see it able to support a variable number of bits, not just 8 bits. As long as it supported shifting out bytes, unsigned ints and longs that would probably be enough. Option to shift out MSB first or LSB first of course.

Nice if it could complete a optional latching output control pulse to the external registers after shifting.

Assignable pins for the clock and data bits would be nice. Higher speed output rather then using the slower arduino digitalWrite commands.

Look forward to what you come up with.


I'd suggest using defines for the debug mode, this will result in a smaller production sketch (sicne the debug statements won't even make it into the sketch this way, if the debug define is set to false, that is).

I wrote a library for using shift registers here I wrote this as an easy way to access the pins on my EZ-Expander product, but it can be used with any shift registers. It currently assumes 2 shift register chips, but that could be generalized. The idea of the library is to make the pins on the shift registers usable in a way similar to ordinary Arduino pins. e.g. expander.digitalWrite(20, HIGH);