Forum Discussion
and gate acting as or and vysa versa
- 7 years ago
Check the logic sense of your switches and LED pins. You are assuming PUSHed=1 and not=0, and out=1 for LED on, and out=0 for LED off.
On many/most all boards pushbuttons will be connected to a pin with a pullup, so the default input will be a '1' (high). When you push it it goes to a '0' (low).
The LED could be driven either active high ('1' high for ON, '0' low for OFF) or active low ('1' high for OFF, '0' low for ON). Check the schematic/docs for which way on your board.
Check the logic sense of your switches and LED pins. You are assuming PUSHed=1 and not=0, and out=1 for LED on, and out=0 for LED off.
On many/most all boards pushbuttons will be connected to a pin with a pullup, so the default input will be a '1' (high). When you push it it goes to a '0' (low).
The LED could be driven either active high ('1' high for ON, '0' low for OFF) or active low ('1' high for OFF, '0' low for ON). Check the schematic/docs for which way on your board.