Maybe someone can help me with this little piece of logic.
I currently use the following method of "bit checking" to identify a "switch" input contained in a byte, then set a particular "relay" output contained in another byte as follows:
SerString(4) is an array containing some serial commands. Outs1 is a 74hc595 output register (classic BS2)
IF Serstring(4) & 004 THEN Outs1 = Outs1 | 002 'if the 3rd bit of Serstring(4) is on then turn on the 2nd bit of Outs1
This works fine...
Now I would like to check 2 bits of SerString(4) at the same time so that both bits must be on for the same function.
IF Serstring(4) & 004 AND Serstring(4) & 016 THEN Outs2 = Outs2 | 002 'if the 3rd and 5th bit of Serstring(4) are both on then turn on the 2nd bit of Outs1
This does not work. I basically get no output. Why? Seems simple enough.
However, even if it does, what I really want to do is make sure Serstring(4) & 004 is ON AND Serstring(4) 016 is OFF to get Outs2 | 002.
What this will do for me is it will keep me from Starting my Engine [Serstring(4) bit 4 is the Start Switch] while the Power Relay that engages the motors [Outs2 bit 2] is on. If the Engine revs up, it can cause my train to suddenly run forward. Its like in your car when you cannot start the car unless it is in park.