Thursday, January 24, 2013

And Or logic gates

Last time we learned about true and false
and how they worked in computers like On and Off switches
turning thousands of light bulbs on and off.

light bulb
(from: wikipedia - incandescent light bulb)

Now think about what would happen if you had two light switches
called switch A and switch B,
and they were hooked up to the same light bulb.

light switch light switch
(from: wikipedia - light switch)

Would you have to have both switches set to ON for it to turn on?
Or is just one good enough?

In computers and electronics, we call that using AND and OR.
So if you need both light switches ON to turn on one light bulb,
that means you need A AND B on.

If the light will turn ON with either switch,
that means A OR B.

When people draw out the AND and OR in pictures,
they sometimes call them logic gates. There are different pictures for an AND gate and an OR gate.

The AND gate sort of looks like a big letter D.
(from: wikipedia - and gate)

The OR gate sort of looks like a spaceship!
(from: wikipedia - OR)

Using those logic gates like switches to turn on and off light bulbs,
you can draw up big pictures that can be used as instructions for building a computer!
(from: wikipedia - logic diagram)