To replace:-
temp = result/1000;
for(byte i = 0; i < temp; i++)
{
b = 1 << 1 | 1;
}
How about
temp = result/1000;
b = (1 << temp) -1;
To replace:-
temp = result/1000;
for(byte i = 0; i < temp; i++)
{
b = 1 << 1 | 1;
}
How about
temp = result/1000;
b = (1 << temp) -1;