I'm trying to do something more complex than it needs to be - 8 bit pwm on an 8 bit 595 shift register. I can shift quite well. Shifting I can do.
Trouble is to calculate 'when' during the numerous updates each individual led should be lit.
Problem arises as such:
I feed the pow function 2 variables, an int and 2
as in, value = pow(2,i);
it returns:
0 = 1
1 = 2
2 = 3
3 = 7
4 = 15...etc
Everything after '2^2' returns its correct value minus one.
Am I crazy? Should I be not feeding it directly 2,i, rather 2 variables? The reference states it will take any float value.
Ultra confusion: Serial.print(value); prints 1.00, 2.00, 3.00, etc
serial.print(value,DEC); prints 1 2 4 8 16...the correct numbers.
value is declared a double.
If you're happy with shifts, try just using bit masks to test your values.
i.e.
val & (1 << x)
It'll be a lot simpler than fiddling with floating point.
Thanks again - so thats like bitset(), bitclear() in short form?
Probably.
(I'm sorry - I'm old-school, program across a variety of platforms, and prefer to program explicitly, rather than depend on locally-defined abstractions. I must get around to reading the reference pages sometime ;D
AWOL, that looks like bitSet and bitClear in long form
Yeah, I know, but I can type that stuff faster than I can reach for the platform reference manual, check that I've got the case right, and the operands in the right order...
;D