Lesson 1. The beam and CD4011
In picturesAfter this lesson the library has the first chip of the CMOS 4000 series — the CD4011, four NANDs in a package, with the same pin names as in the Texas Instruments datasheet — and an IR beam works on the canvas: block it and the "someone passed" lamp lights up and stays on until Reset is pressed.
1.1. Idea: how a shop counts people
At the shop entrance, at waist height, there are two invisible beams: an emitter on one side of the door, a receiver on the other. While the doorway is free the beam gets through and the receiver gives 1. A person blocks the beam — the receiver gives 0. The whole kit is about turning these zeros and ones into two numbers on the displays: how many people are inside now and how many came in today.
1.2. Idea: the CMOS 4000 series
In 1968 RCA released the CMOS 4000 series — chips on pairs of P and N transistors, exactly like our gates. They ran on a battery and hardly warmed up, so they went into watches, calculators and counters. The pin numbers and names are from the Texas Instruments datasheet; TI still makes these chips.
- CD4011 — four NANDs. Inputs
A–H, outputsJ–M; - pin 7 — VSS (ground), pin 14 — VDD (power). Our power is shared, so these pins are not there.
1.3. Idea: NAND for everything
Anything can be built from NANDs alone, so in this kit all the direction logic is on CD4011:
- a NAND with its inputs joined is a NOT:
XA= NOTBA; - two NANDs crossed are a latch: a zero on one input sets it to 1, a zero on the other — to 0, ones on both — it remembers.
1.4. Build
A new project. You need the gate NAND — from lesson 0 or any kit of the series.
Step 1. Chip CD4011 — 4 × NAND
Package pins from the TI datasheet: 1 A, 2 B, 3 J, 4 K, 5 C, 6 D, 8 E, 9 F, 10 L, 11 M, 12 G, 13 H; 7 — VSS (ground), 14 — VDD (power) — our power is shared by all chips, so these pins are not there. Port name = pin name: double-click a port → A and so on. The gates inside: A·B → J, C·D → K, E·F → L, G·H → M.
| Part | Pin | Label |
|---|---|---|
| Input port | output | A |
| Input port | output | B |
| Input port | output | C |
| Input port | output | D |
| Input port | output | E |
| Input port | output | F |
| Input port | output | G |
| Input port | output | H |
| Output port | input | J |
| Output port | input | K |
| Output port | input | L |
| Output port | input | M |
| NAND | I0 I1 O0 | A B J |
| NAND | I0 I1 O0 | C D K |
| NAND | I0 I1 O0 | E F L |
| NAND | I0 I1 O0 | G H M |
Ctrl+G → name CD4011. Legs: inputs A, B, C, D, E, F, G, H; outputs J, K, L, M.
Step 2. Power, IR pair and button
IR pair — the Sensors palette: the emitter E1 and the receiver R1 are placed together on channel 1, with the beam between them. The emitter shines while its input is 1 — we put it on VCC. The receiver gives 1 while the beam gets through and 0 when the beam is blocked.
| Part | Pin | Label |
|---|---|---|
| Power | output | VCC |
| Ground | output | GND |
| IR pair: emitter E1 | In | VCC |
| IR pair: receiver R1 | Out | BA |
| Button «Reset» | output | RST |
Step 3. One CD4011 — three jobs
Gate A B → J: both inputs on the beam — a NAND with equal inputs works as a NOT: XA = 1 when the beam is blocked. Gate C D → K inverts the button the same way: nRST. Gates E F → L and G H → M crossed — a latch: the beam is blocked (BA = 0) — SEEN = 1 and it stays even when the beam is whole again, until Reset is pressed (nRST = 0).
| Part | Pin | Label |
|---|---|---|
| CD4011 | A B J K C D E F L M G H | BA BA XA nRST RST RST BA SEENN SEEN SEENN nRST SEEN |
Step 4. Lamps
XA — the beam is blocked now, SEEN — someone passed (remembered).
| Part | Pin | Label |
|---|---|---|
| LED | input | XA |
| LED | input | SEEN |
1.5. Check
- Press Reset: both lamps are off.
- Press the beam between
E1andR1and hold — the beam is blocked:XAandSEENlight up. - Let go — the beam is whole again:
XAgoes out, butSEENstays lit — the latch remembers that someone passed. - Reset —
SEENgoes out. Alt/⌘+ click on the beam — the beam is blocked and fixed (a cross bar on the beam); the same click clears it. This is how several beams are blocked at once — you will need it in lesson 5.
| What you did | XA | SEEN | What it is |
|---|---|---|---|
| Reset | ○ | ○ | nobody was here |
| blocked the beam | ● | ● | a person in the beam |
| let go of the beam | ○ | ● | the person passed — remembered |
| Reset | ○ | ○ | forgotten |
Lesson 1 paste (Cmd+I)
You need the gate NAND (lesson 0). The paste is the CD4011 chip and the beam with the latch.
# Lesson 1 — the beam and CD4011: an IR pair, a 4 × NAND chip and the "someone passed" latch.# Paste: Cmd+I into a project with the NAND gate (lesson 0). chip CD4011 { portIn(A) portIn(B) portIn(C) portIn(D) portIn(E) portIn(F) portIn(G) portIn(H) portOut(J) portOut(K) portOut(L) portOut(M) NAND(A, B, J) NAND(C, D, K) NAND(E, F, L) NAND(G, H, M)} power(VCC)ground(GND)irtx{channel=1}(VCC)irrx{channel=1}(BA)button{label="Reset"}(RST)CD4011(A=BA, B=BA, J=XA, K=nRST, C=RST, D=RST, E=BA, F=SEENN, L=SEEN, M=SEENN, G=nRST, H=SEEN)led(XA)led(SEEN)Stuck? Something doesn't work →