Picaxe = 28x1 OR 40x1.
I need to set three 'alarms' either On or Off. I thought of using one byte for this called 'Albits' (=b16). I want to use the three lower bits example: if alarms 3 and 1 are ON and 2=Off then the byte would look like this - %00000101, correct ?
If an alarm situation is recognised for alarm-2, and I want to set its bit to on (set to %00000111) but also retain the other two already on, how do I use the '&' command ? Same applies if the alarm-2 situation is cleared and must be reset (set to %00000101) but alarms 3 and 1 are still active.
I've looked in manual 2 (Basic Commands) but can't quite see how to do this. How do I apply the mask to retain the current bits as they are but change the one bit, other than pumping in numbers such as 'albits = 5' (%00000101) ?
Help me please.
Manie
I need to set three 'alarms' either On or Off. I thought of using one byte for this called 'Albits' (=b16). I want to use the three lower bits example: if alarms 3 and 1 are ON and 2=Off then the byte would look like this - %00000101, correct ?
If an alarm situation is recognised for alarm-2, and I want to set its bit to on (set to %00000111) but also retain the other two already on, how do I use the '&' command ? Same applies if the alarm-2 situation is cleared and must be reset (set to %00000101) but alarms 3 and 1 are still active.
I've looked in manual 2 (Basic Commands) but can't quite see how to do this. How do I apply the mask to retain the current bits as they are but change the one bit, other than pumping in numbers such as 'albits = 5' (%00000101) ?
Help me please.
Manie