Gate lab
Two buttons drive an AND, an XOR and a NOT, so the truth table lights up as you press. There is no microcontroller in it: the simulator solves the 13 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.
BeginnerRuns in your browser. Free, and no account needed.
How it works
There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.
// A logic lab: AND, XOR and NOT, wired by hand.
//
// Hold button A, button B, or both, and read the three LEDs:
//
// A B AND XOR NOT A
// 0 0 0 0 1
// 1 0 0 1 0
// 0 1 0 1 1
// 1 1 1 0 0
//
// The two 10 k resistors are pull-downs. A button can only connect a net to
// something; it cannot disconnect it. Without the pull-down the gate input
// would be left floating the moment you let go, and a floating CMOS input is
// not a zero. It is whatever the last charge on it happened to be.
//
// The gates here are the ideal kind: no supply pins, a few nanoseconds of
// propagation delay, and a push-pull 5 V output. The 74HC chips in the other
// examples are the real thing, with a supply you have to wire and a delay you
// can measure.
Parts list
15 parts, plus the jumper wires. Every one is in the editor's parts bin.
- 1 × Full-size breadboard
- 1 × Power, 5 V
- 2 × Pushbutton
- 2 × Resistor, 10k Ω
- 2 × Logic gate
- 1 × Inverter
- 3 × Resistor, 220 Ω
- 1 × LED, green
- 1 × LED, yellow
- 1 × LED, blue
How it is wired
10 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- 5 V: Pushbutton (1) pin 2a; Pushbutton (2) pin 2a
- Ground: Resistor, 10k Ω (1) pin 1; Resistor, 10k Ω (2) pin 1; LED, green pin C; LED, yellow pin C; LED, blue pin C
- Pushbutton (1) pin 1a; Resistor, 10k Ω (1) pin 2; Logic gate (1) pin A; Logic gate (2) pin A; Inverter pin A
- Pushbutton (2) pin 1a; Resistor, 10k Ω (2) pin 2; Logic gate (1) pin B; Logic gate (2) pin B
- Logic gate (1) pin Y; Resistor, 220 Ω (1) pin 1
- Logic gate (2) pin Y; Resistor, 220 Ω (2) pin 1
- Inverter pin Y; Resistor, 220 Ω (3) pin 1
- Resistor, 220 Ω (1) pin 2; LED, green pin A
- Resistor, 220 Ω (2) pin 2; LED, yellow pin A
- Resistor, 220 Ω (3) pin 2; LED, blue pin A
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.