I was looking at playing around with PORT manipulation as I require to control several pins at one go ( trying to read parallel data & also to set different outputs at the same time) now i figured it is possible to do this easily with PORT manipulation and was looking at the tutorial. I cant seem to understand a few things and would appreciate if someone can clarify or explain a bit in detail...
How do i read the inputs from say PORTB? can i simply say
int input_value;
input_value = PINB;
Now how many bits will this return? i presume 6 bits and if it returns 6 bits how will it be assigned to the integer variable? lets say PINB reads '110011' what will the value stored in input_value?
finally what will read on the analog PORTC return? if its binary data, how do i get the corresponding analog values?
I know too many questions, but it all seems very interesting all of a sudden
This returns 8 bits but only 6 are meaningful for this port.
lets say PORTB reads '110011' what will the value stored in input_value?
It is simply the binary value 110011, all numbers are binary, if you get it to print this as hex it will read 33, in decimal it will be 51 but it will still be 110011 inside the Arduino.
finally what will read on the analog PORTC return
The logic value of the bits on each pin, if you are putting analogue values on it then it depends if these values are above or below the logic threshold.
how do i get the corresponding analog values
By using analogRead(), or by selecting the appropriate multiplex input, initiating a conversion and reading the results register when it is finished, all by banging bits in other resisters. (but why bother)