Logic for beginners
This post is for everyone who enjoyed the blog „Arduino for dummies“. Today´s topic is logic and I´m writing again as a beginner We´ll have a closer look at the following gates: AND, OR, NAND, NOR. The sequel wil go online next month.
Let´s start with the AND. If only one button is pressed, the LED won´t turn bright. Only if the first AND the second button is pressed, the LED will light up. Now we already understand the concept of the first gate! To make everything more clearly and mathematical we can display AND in a truth table. 1 means button is pressed and 0 means button is not pressed. A and B symbolise the two buttons. In the last column you can see a Y, this symbolises the output. In this column 1 means LED lights up, 0 means that the LED stayes dark.
The second circuit is already waiting: OR. In short: the LED lights up if one or both buttons are pressed. Therefore the truth table looks like this:
Now we´re going to face an interesting gate: The NAND gate. Why is this gate interesting? You can realise all logical circuit with NAND and NOR (we´ll come back to that gate in a second). NAND is somehow the opposite of AND. The LED lights up if one or no button is pressed and only shuts off if both buttons are pressed. Here is the truth table for NAND:
Just as NAND is somehow the negative pendent of AND, NOR fits with OR. In short: If one or both buttons are pressed, the LED is dark. Just as said before: NOR is also a special gate. It can be displayed with a AND and NOT gate. The NAND can be realised with a OR and NOT gate.