Hi,
In the first code you posted you read the status of PortB before driving the the common pin for the encoder so there probably won't be any signals comming in.
In the second, updated example, you never drive the common pin for the encoder at all.
You need to set the "common pin" high (or low depending on hardware) and THEN read the port otherwise you won't get anything back.
You really need to sit back and think the problem thru, not just cut and paste pieces of code together without understanding what they do and how the hardware they're intended to interface to is supposed to work.
Think it thru.... The "encoder" has a "wiper" which "cylces" thru the different contacts. Depending on which contact the wipers is positioned at you'll get a signal out on a certain pin. In order to get that signal out the "wiper" must be "powered" in one way or another. If the inputs from the "contacts" are pulled up then wiper must be grounded so that it pulls the contact (and signal LOW). Likewise if the inputs from the contacts are pulled down then the "wiper" must be high in order to pull the inputs high.
If the inputs are pulled up with resistors then you'll get a "walking zero" across the three pins, if the inputs are pulled down you'll get a "walking one" across the inputs. You must adapt the code to match.
My suggestion, for now, is that you ditch the matrix routine untill you get the encoder working - and understand how it works.
/Henrik.
Bookmarks