Ardhuino Shift Register – 74HC595 notes

So, I am still playing with Arduino, and want to understand the shift register better.  Notes as I go.

  • I used this official page to get up and running.  I set it up and got the “Hello World” sketch running.  It was all very deja vu and I realised that I’d been through all this before without really getting to grips with it (running before I could walk).  My eureka moment was realising that you address the 8 pins all at once by a binary number up to 255.  Suddenly it all makes sense (255 = 11111111 in binary so turns all 8 inputs HIGH, 129 is 10000001 which turns the first and last inputs HIGH.
  • function bitWrite appears to replace the bit in a binary number, so bitWrite(0,4,1) would change the number 0 to the number 1000 by placing a 1 4 digits in to the binary number.  bitWrite(16,2,1) would change 1000 to 1010.  The first parameter is the variable you are changing.
  • function ShiftOut fires out the bits in order then toggles the clock pin to tell the register the data is there.