Counting hexadecimal / binary

for example, if i have an register 0x00 and i want to count up to let´s say 0xff each step in a loop ?? i want to make a function and just pass the variable between the increasing steps (0x01,0x02,....0xdf, 0xef,0xff).

any code out there? don´t even know how to start!

thanks

like this?

int i;
for (i = 0x0; i <=0xff; i++)
{
    fn_whatever(i);
}

-j

yeah! great! well, i was also interested in a solution writtten in C, as i it wouldnt be that easy like the above.

but thanks a lot! it works.

i was also interested in a solution writtten in C, as i it wouldnt be that easy like the above.

I don't understand this statement; that is C code. Of course, being C, it's also C++, "Arduino" code, etc.

C doesn't care if the constants are hex (0xff), octal (075), decimal (6789), or even ASCII ('c'). It doesn't know about binary constants, but somone wrote a macro to handle that, I think included in Arduino 7.

-j

sorry, you are right! but i´ve another question which is hard to find through all references. how can i "eval" within arduino language. for example, i have some registers called reg_level0, reg_level1, reg_level2 ...
i want to set some bytes in a for-statement such as

for (i = 0; i < 5; i++) {
function_blablab(reg_level[i], 0x00);
}

of course above example couldnt be compiled as it interprets the square brackets as an array? do you know another syntaa for that?

thanks

I don't think what you're asking is possible.

My first thought is to put them into an array instead of having several discrete values.

-j

yep, workaround is indeed an array, here´s the code

byte reg_level0 = 0x01;
byte reg_level1 = 0x02;
byte reg_level2 = 0x03;
byte reg_level3 = 0x04;
byte reg_level4 = 0x05;
byte reg_level[5] = { reg_level0, reg_level1, reg_level2, reg_level3, reg_level4  };

void test(int i) {
for (i = 0; i < 5; i++)  {
  function_blalba(reg_level[i], 0x40);
  delay(delaytime);
 
}
}