problem trying to write binary bits to pins.

I have a little problem, and don’t know how to solve it.

I’ve got 16 Address lines to where i need to write 16 pins high or low depending on the hex number(hex number determines what pin goes high.)

this is what I’ve tryed:

  //Read addresses 0000h to 3FFF, i.e. ROM bank 0
        for (addr = 0; addr <= 0x3FFF; addr++){
          IOexp.digitalWrite(0,0, HIGH && (addr & B0000000000000001));
          IOexp.digitalWrite(0,1, HIGH && (addr & B0000000000000010));
          IOexp.digitalWrite(0,2, HIGH && (addr & B0000000000000100));
          IOexp.digitalWrite(0,3, HIGH && (addr & B0000000000001000));
          IOexp.digitalWrite(0,4, HIGH && (addr & B0000000000010000));
          IOexp.digitalWrite(0,5, HIGH && (addr & B0000000000100000));
          IOexp.digitalWrite(0,6, HIGH && (addr & B0000000001000000));
          IOexp.digitalWrite(0,7, HIGH && (addr & B0000000010000000));
          IOexp.digitalWrite(1,0, HIGH && (addr & B0000000100000000));
          IOexp.digitalWrite(1,1, HIGH && (addr & B0000001000000000));
          IOexp.digitalWrite(1,2, HIGH && (addr & B0000010000000000));
          IOexp.digitalWrite(1,3, HIGH && (addr & B0000100000000000));
          IOexp.digitalWrite(1,4, HIGH && (addr & B0001000000000000));
          IOexp.digitalWrite(1,5, HIGH && (addr & B0010000000000000));
          IOexp.digitalWrite(1,6, HIGH && (addr & B0100000000000000));
          IOexp.digitalWrite(1,7, HIGH && (addr & B1000000000000000));

the compiler just says that B0000000000000001 is not declared in this scope?
do I need to declare them? if so as what?

Use " 0b0000000000000001 " instead The "Bxxxxxxxx" macros are only defined for eight bit numbers.

Use " 0b0000000000000001 " instead

Or hex, 0x0001. Less typing. Still tastes great.

Thank you guys :)

or use the AVR macro _BV() for simplicity and clarity to create the bit mask.
(I find using binary like that very subject to typing errors)

_BV(0) is bit 0
_BV(13) is bit 13


(addr & _BV(13))
instead of
(addr & 0b0010000000000000)

If you don’t want to depend on an AVR macro,
then you can simply define your own, which I frequently do for
portability reasons.

#define BIT(x) (1 << x)

Then you can use
BIT(0) for bit 0 mask
BIT(13) for bit 13 mask.

So now you have:
(addr & BIT(13))

Which, at least for me, is very easy to read.

Another valuable thing when using the bit macros over a simple constant
for a bit mask is that you can use them with variables as well.

— bill

#define BIT(x) (1 << x)

Make that:
#define BIT(x) (1 << (x)) just to be safe.

You all guys are really amazing)... If any of you be my mentor i would have conquer the Universe.. Thank You all Sir.

yes I want to say thank you two! :)