My question will be specific to Arduino, although if you know how to do this in C, it will also be similar to the Arduino IDE.
So, I have 5 integer variables:
r1, r2, r3, r4, r5
Their value is 0 (off) or 1 (on). I would like to store them in a byte variable, let the relay call it, not by adding them, but setting certain bits to 1/0 regardless of whether they are 0 or 1. For example:
1, 0, 0, 0, 1
I would like to have the same value in my byte byte variable, not r1 + r2 + r3 + r4 + r5, which in this case will be decimal 3, binary 11.
Thank!
source
share