So, I’ve been sitting on two shift-registers I got for my Arduino for a few weeks, without getting around to actually doing anything with them. I finally decided enough was enough, and I cooked up a binary counter which counted to 31. All I used was a shift-register, 3 I/O-pins, and a handfull of 1kΩ resistors. Using the provided example in the Arduino-IDE I gobbled together my own Arduino sketch which first cycles through the LED’s and then counts to 31 over and over. Currently I only have the video, but I’ll add the source code and a diagram later on, when I get home to the computer with the sketch on it.
What is a shift-register?
The advantage to using a shift register compared to not using a shift-register is, that you can “extend” your 10 I/O pins on the Arduino to a practically unlimited number. You will be using only 3 pins on the Arduino (apart from 5V and GND). The three pins are used for a latch-pins, a timer pin and a data-pin. The shift-register takes a serial signal, and sends it to the 8 out-pins on the shift-register, which then outputs them, once the latch-pin goes to ‘HIGH’. If you need to control more than 8 outputs, you connect another shift-register to the overflow pin on the shift-register, and the remaining bits are sent to the extra shift-register and so on.
For example, if I send binary 153 (10011001) to the shift-register, the pins 8, 5,4, and 1, will be set to ‘HIGH’ once the shift-register gets the all-ok signal (the latch-pin going to ‘HIGH’). In my example I only used 5 LED’s, so the highest number I could show, was 11111 (16+8+4+2+1 = 31).
What does my arduino project do?
My counter/gadget starts out by cycling the LEDs a la KITT (of Knight Rider fame). Once that is done, the counter starts counting in binary. Once the highest available number is reached, it resets the counter and starts over.
Basically the sketch is just a bunch of for-loops. At the top of the sketch I define the number of LEDs connected to the shift-register. Throughout the sketch, I refer to that number when setting the range of the loops. The Arduino sends the appropriate number, formatted as binary, to the shift-register. When the number has been received, the latch-pin is set to HIGH and the shift-register sets the pins as instructed.
Where to go from here?
The possibilities of using a shift-register with an Arduino is almost limitless. Just the fact that it frees up I/O pins makes it a great tool for your projects. The next step for me, would be to either a) get it to work with an LCD, or b) get my hands on a shift-out register. That way I can do the same thing, just for inputs. Currently I have an idea of making a intervalometer with a menu-system, which’ll require at least 4 input-pins.
I realized I didn’t have the time to develop my own webpage/CMS from the bottom up. Between all the other projects I’m working at, I had to prioritize. Rolling my own system would end up in me reinventing the wheel over and over. Instead I chose to take the opportunity to try out wordpress.
First of all, wordpress is a widely used system and comes packed with tons of features. The features which isn’t build in, will most probably be available in the form of a plugin. Furthermore, I’m not a designer, so using one of the many themes out there is a given. Furthermore, I save a ton of time by not implementing stuff already done by others. Lastly there is tonnes of guides on the internet on how to perform SEO on a wordpress-installation, one of the most notorious being yoast who has also made a great plugin.
This is just the first installation with an other-than-default theme, and I’ve only scratched the surface of plugins and what is possible. I have tons of ideas, both for posts and for features, so stay tuned or follow me on twitter.