https://mbed.org/users/yoonghm/code/ShiftReg/#a0e3fd47970f