shiftOut

Dear all,
I read this tutorial and I was confused about the MSBFIRST/LSBFIRST. Can anyone provide me an example how to illustrate the difference between this two ? If my number is 00000001, then it will shift the 0 first if it is MSBFIRST ? If my LEDs are numbered 1 to 8 from left to right assuming the most right is the LSB. So, I am confuse here.

Thanks for help :slight_smile:

"If my number is 00000001, then it will shift the 0 first if it is MSBFIRST ?" Yes.

"If my LEDs are numbered 1 to 8 from left to right assuming the most right is the LSB." So number them 7 to 0 from left to right. Then they will match up with your data. The lowest place of anything should always be position 0.
Look at how the data goes thru the shift register as well - from Qa to Qh. So Qa is the LSB and Qh is the MSB.
So your example 00000001 will end with Qh-g-f-e-d-c-b-a as 0-0-0-0-0-0-0-1.

74hc595_TI.pdf (915 KB)

I get confused to.
what I usually do is just do it with either LSB or MSB first.
if that doesn't work right, just do the other one.
It's a 50 50 chance you'll end up with the right one

CrossRoads:
"If my number is 00000001, then it will shift the 0 first if it is MSBFIRST ?" Yes.

"If my LEDs are numbered 1 to 8 from left to right assuming the most right is the LSB." So number them 7 to 0 from left to right. Then they will match up with your data. The lowest place of anything should always be position 0.
Look at how the data goes thru the shift register as well - from Qa to Qh. So Qa is the LSB and Qh is the MSB.
So your example 00000001 will end with Qh-g-f-e-d-c-b-a as 0-0-0-0-0-0-0-1.

So if MSB first, suppose the sequence should be reverse ? Assuming the data shift from left to right. So MSB first means Qh first and Qh will get shifted to the LSB position isnt that ?

Thanks !

No, the shift register only goes one way, from Qa to Qh.
If you want to shift LSB first, then Qh would end up with the LSB.

Okay I think I get it now. The key is that 'it starts from Qa'

So if my example is 00000001, and order type is MSBFIRST, the 1 will be shift first ?

Thanks ! :slight_smile:

If I want to shift the number 00000001, then Qa will output 0 and be placed at MSB position and Qh will have value of 1 and position at the LSB ?

Is that what MSBFIRST/LSBFIRST means ?

Thanks !

As written, MSB - 00000001 - LSB.

MSBFirst results in:
Qh-g-f-e-d-c-b-a are MSB - 0-0-0-0-0-0-0-1 - LSB with MSB/LSB referring to the shift register

LSBFirst results in:
Qh-g-f-e-d-c-b-a are MSB - 1-0-0-0-0-0-0-0 - LSB.

So MSBFIRST/LSBFIRST is a software thing, and you have to check to make sure that is in sync with your hardware.