hmmm. Did Paul McWhorter lie to me?
So this code is supposed to stop the butUpVal to got above 255 and stop the butDownVal go below 0.
if(butDownVal<0){
butDownVal=0;
}
if(butUpVal>255) {
butUpVal=255;
}
what is wrong Im wondering.
2 Replies
can't really see anything wrong with that short code you provided, but possibly, if you use uint8_t for butDownVal and butUpVal, and try to assign beyond their limits (0-255), it will overflow. for example, if you try to assign 256, it woud actually assign 0, 257-1,258-2, so on. same applies if you use signed 8 bit ints (int8_t), which are from -128 to 127
oukei thank you