Arduino Logic
Arduino Logic
The purpose of a NOT gate in digital logic is to invert the input. If the input is HIGH,
the output is LOW and vice versa. It's a very simple matter to replicate this on the
Arduino. We need one pushbutton and one LED as a visual indicator of the logic
status. So, let's set up a pushbutton to bring a pin reliably low. Here's how:
I use the larger two-terminal buttons for preference because they aren't as fiddly to
wire and if I'm doing it on a breadboard they're more suited. Whichever you use,
here's how to wire:
shop floor, or disabling alarms when not needed. It can also be used where two
consenting operators are needed, such as weapons launching.
Arduino Logic: OR
An OR gate will have a high output when either or both of its inputs are high, and a
low output when neither of its inputs are high. The wiring can be done in exactly the
same way as for the AND gate:
Each conditional refers in turn to the input pins as being high or low. There are four
possible combinations:
The latter two is what these conditionals look for and if found the variable LEDON is
set to true. It can't go back to false until the loop starts again and so now we've got
a reference for an if...else statement:
if (LEDON==true){digitalWrite (2,1);}
else{digitalWrite (2,0);}
An XOR can be used as a pause/interrupt to stop a device doing whatever it does
temporarily until the second pulse is removed without resetting or switching off the
rest of the device.
http://ianlangelectronic.webeden.co.uk/#/arduino-logic/4571280726