Binary Logic
alnajjar1
Posts: 110
Hello,
I am using a 74HC165 to listen to 8 switches. I then use the byte I get from the 165 to turn on LEDs that are connected to pins 0-7 or OutL. The problem is that I want to turn the LEDs only when there is a change from 0 to 1 on the switch and not 1 to 0. I can do this by looking at the change in condition in each bit of the 165 input and turn individual LED on/off. the problem is this is very slow. I need to work with the entire byte.
Here is an example of how I want the logic:
Switches from %01000000 --> %00000101 then OUTL = %00000101
I essentially want to activate the LED "on mouse down" and do nothing on "mouse up" to use a PC comparison.
I have seen some binary operation in Scott Edwards article in Nuts&Volts on Rotary Encoders example where he uses the XOR operator. The problem is that I want to work with the entire byte and not its individual bits since speed is of the essence.
Any idea how I can achieve this?
Many thanks in advance,
Al
I am using a 74HC165 to listen to 8 switches. I then use the byte I get from the 165 to turn on LEDs that are connected to pins 0-7 or OutL. The problem is that I want to turn the LEDs only when there is a change from 0 to 1 on the switch and not 1 to 0. I can do this by looking at the change in condition in each bit of the 165 input and turn individual LED on/off. the problem is this is very slow. I need to work with the entire byte.
Here is an example of how I want the logic:
Switches from %01000000 --> %00000101 then OUTL = %00000101
I essentially want to activate the LED "on mouse down" and do nothing on "mouse up" to use a PC comparison.
I have seen some binary operation in Scott Edwards article in Nuts&Volts on Rotary Encoders example where he uses the XOR operator. The problem is that I want to work with the entire byte and not its individual bits since speed is of the essence.
Any idea how I can achieve this?
Many thanks in advance,
Al
Comments
Clever, but "!" should be "~" for bitwise not in PBasic.
I also tried yesterday (and it worked) inverting the byte from the 165 using the NOT (multiplying by -) then using the AND NOT operator which gives a byte indicating the changes of 0 to 1 on all bits. This was straight from the manual. I always find these logic operators complicated to understand..
many thanks for the quick response.
Al