Go Down

Topic: Cascaded shiftin skips first zeros? (Read 609 times) previous topic - next topic

dglstrp

Hey all,
I've been searching the forums and can't find an answer to this issue.
I'm thinking I'm doing something stupid, but you know you never find it till you hit post.

I am going through the shiftin tutorial and have added a third 4021 to read the status of three 8 position dip switches.

I can read all three, but if the second or third has any of the switches off as you read from 0-7, the returned data ignores those and just shows the 3rd, 4th, or whatever starting first bit is on.

So I can get all 8 bits on the first 4021, then depending on the settings I'll get 4 or 5 bits and sometimes a single 0 if no switches were set on the others


I am planning to read each of the switches 8 bits and assign values in a program based on the settings, but I am trying to use each of the 4021's to read two 4bit values.
Does that make sense? The first half of 4021 A is one value while the second half is another value and so on for 6 value settings altogether.

Skipping initial 0 inputs on 4021 b & c won't work.

Also, while I'm here, I want to read the 1's and 0's of each bit and convert to a decimal number then do some fancy math.

So I need to read all 24 1's and 0' then break into 6 values, can someone point me at a way to pick out each bit and convert it?
In reading through the forums, I'm thinking the next tutorial should be getBit().

Am I going in the right direction there?

dglstrp

OK nevermind, it only skips when printing to screen, when I put the data in an array and they retrieve it it is all there.

Go Up