I think you are getting confused with the number and definition of the PortXBit....
This is from Globals.h:
Code: Select all
// Outlets on Relay box
#define Port8 8
#define Port7 7
#define Port6 6
#define Port5 5
#define Port4 4
#define Port3 3
#define Port2 2
#define Port1 1
// Port bits
#define Port8Bit 1<<7
#define Port7Bit 1<<6
#define Port6Bit 1<<5
#define Port5Bit 1<<4
#define Port4Bit 1<<3
#define Port3Bit 1<<2
#define Port2Bit 1<<1
#define Port1Bit 1<<0
Which define easier to use numbers, so we don't need to do the bit shifting or bit manipulation manually.
These numbers are meant for use on our functions.
So, Port5Bit is the same as binary B00010000, which is the same as hex 0x10, which is the same as decimal 16.
If you use a function like this:
Code: Select all
ReefAngel.FeedingModePorts = Port4Bit;
It will be the same as this:
Now, if you look at the bitRead function here:
http://arduino.cc/en/Reference/bitRead
You will see that the function calls for a bit position and not the decimal value of where the bit is located in a byte variable.
Bit shifting and bit math can be a little confusing at first.
Roberto.