I want to reset a count value to 0 after reaching a certain limit. And return the value which is (originalCount - limit).
I have tried if
and for
loops but cannot achieve what I want.
//payload is an array of bytes//
if (payload[0] == 33) {
result.PayloadTtype = 'Vehicle Count';
if (payload[2] > 80) {
payload[2] -= 80; //Sensor Reboot due to exceeding limit
result.Count = payload[2];
}else {
result.Count = payload[2];
}
}
I can return correct values up to 159 but once it exceeds 160 on wards it prints (80,81....)
. I want it to start again from 0 even for multiples of 80n (n = 1,2,3...)
.