{"base":{"id":"cs10-27","subject":"Computer systems","title":"Logic gates and truth tables","scene":"mix","steps":[{"use":"cs10t3","mode":"gates","eyebrow":"NOT, AND, OR","title":"The three basic gates","body":"A logic gate takes binary inputs and gives one binary output. Choose a gate, then tap A and B to change the inputs.","controls":[{"id":"g","label":"Gate (0 NOT · 1 AND · 2 OR)","min":0,"max":2,"step":1,"value":1,"hideValue":true}],"actions":[{"id":"a","label":"Toggle A"},{"id":"b","label":"Toggle B"}]},{"use":"cs10t3","mode":"gates","eyebrow":"NAND, NOR, XOR","title":"Three more gates","body":"NAND and NOR are AND and OR with the output flipped. XOR gives 1 when the inputs are different.","controls":[{"id":"g","label":"Gate (3 NAND · 4 NOR · 5 XOR)","min":3,"max":5,"step":1,"value":5,"hideValue":true}],"actions":[{"id":"a","label":"Toggle A"},{"id":"b","label":"Toggle B"}]},{"use":"code","mode":"and","eyebrow":"Logic in programs","title":"Both must be TRUE","body":"The same logic appears in IF statements: a ride needs height ≥ 130 AND age ≥ 8. Change the inputs.","controls":[{"id":"height","label":"Height","min":100,"max":160,"step":5,"value":130,"unit":"cm"},{"id":"age","label":"Age","min":5,"max":14,"step":1,"value":10}]},{"use":"code9","mode":"light","eyebrow":"Logic in devices","title":"A light level decides","body":"A night light switches on when it is dark AND movement is detected. Sensors give the inputs, logic decides the output.","controls":[{"id":"light","label":"Light level","min":0,"max":100,"step":5,"value":30}]},{"use":"cs10t3","mode":"quiz","look":"gates","eyebrow":"Check yourself","title":"XOR","body":"An XOR gate has inputs A = 1 and B = 1.","question":"What is the output?","options":["1","0","It depends on the clock"],"answer":1,"right":"Correct. XOR outputs 1 only when the inputs are different.","wrong":"Not quite. XOR means \"one or the other, but not both\"."}],"more":[{"type":"cards","id":"worked","eyebrow":"Worked examples","title":"Step by step","items":[{"tag":"Truth table","title":"AND","body":"A B | X\n0 0 | 0\n0 1 | 0\n1 0 | 0\n1 1 | 1","code":true},{"tag":"Truth table","title":"XOR","body":"A B | X\n0 0 | 0\n0 1 | 1\n1 0 | 1\n1 1 | 0","code":true},{"tag":"Rows","title":"How many rows?","body":"1 input → 2 rows\n2 inputs → 4 rows\n3 inputs → 8 rows (2ⁿ)","code":true},{"tag":"Real life","title":"Car warning","body":"buzzer = door_open AND engine_on","code":true}]},{"type":"cards","id":"detail","eyebrow":"The ideas in detail","title":"Six gates","items":[{"tag":"NOT","title":"Inverter","body":"One input. Output is the opposite of the input."},{"tag":"AND","title":"Both","body":"Output 1 only if A = 1 and B = 1."},{"tag":"OR","title":"Either","body":"Output 1 if A = 1 or B = 1 or both."},{"tag":"NAND","title":"NOT AND","body":"Output 0 only if both inputs are 1. Any circuit can be built from NAND gates alone."},{"tag":"NOR","title":"NOT OR","body":"Output 1 only if both inputs are 0."},{"tag":"XOR","title":"Exclusive OR","body":"Output 1 if the inputs are different. Used to add binary digits."}]},{"type":"cards","id":"mistakes","eyebrow":"Common mistakes","title":"Watch out for these","items":[{"tag":"Mistake","title":"Confusing OR with XOR","body":"OR gives 1 when both are 1; XOR gives 0."},{"tag":"Mistake","title":"Missing rows","body":"List inputs in binary order 00, 01, 10, 11 so none is missed."},{"tag":"Mistake","title":"Forgetting the bubble","body":"The small circle on NAND, NOR and NOT means \"invert\"."}]},{"type":"cards","id":"deeper","eyebrow":"Go deeper","title":"More than the lesson","items":[{"tag":"How it works","title":"Transistors","body":"Each gate is built from a few transistors acting as switches. A modern processor has billions of them, switching billions of times a second."},{"tag":"History","title":"George Boole and Claude Shannon","body":"In 1854 George Boole wrote an algebra of TRUE and FALSE. In 1937 Claude Shannon showed it could describe electrical switching circuits, laying the foundation for digital computers."},{"tag":"Going further","title":"Half adder","body":"An XOR gate and an AND gate together add two bits: XOR gives the sum digit and AND gives the carry."}]},{"type":"cards","id":"challenge","eyebrow":"Challenge yourself","title":"Stretch your brain","intro":"Try each one on paper before opening the card.","items":[{"tag":"Challenge","title":"Half adder","body":"Complete the outputs Sum (XOR) and Carry (AND) for A = 1, B = 1.\n\nAnswer: Sum 0, Carry 1 (1 + 1 = 10 in binary)."},{"tag":"Challenge","title":"Identify","body":"A gate gives 1 for inputs 00 only. Which gate?\n\nAnswer: NOR."},{"tag":"Challenge","title":"Universal","body":"How can a NAND gate act as a NOT gate?\n\nAnswer: connect both inputs together: NAND(A, A) = NOT A."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Try it yourself","items":[{"title":"Two-switch lamp logic","time":"15 minutes","need":["Paper and pencil"],"steps":["Draw two light switches in series and in parallel.","For each, make a truth table: switches as inputs, lamp as output.","Match each circuit to a logic gate."],"why":"Series switches behave like AND; parallel switches behave like OR.","safety":"Do not open real wall switches or sockets."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Eight more questions","questions":[{"question":"AND with inputs 1 and 0 gives…","options":["1","2","0"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"OR with inputs 0 and 0 gives…","options":["0","1","undefined"],"answer":0,"right":"Correct.","wrong":"Not quite."},{"question":"NOT 1 =","options":["1","0","−1"],"answer":1,"right":"Correct.","wrong":"Not quite."},{"question":"NAND with inputs 1 and 1 gives…","options":["1","11","0"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"How many rows in a 3-input truth table?","options":["8","6","3"],"answer":0,"right":"Correct.","wrong":"Not quite."},{"question":"Which gate outputs 1 only when inputs differ?","options":["AND","XOR","NOR"],"answer":1,"right":"Correct.","wrong":"Not quite."},{"question":"The small circle on a gate symbol means…","options":["a clock","an extra input","the output is inverted"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"NOR with inputs 0 and 0 gives…","options":["1","0","error"],"answer":0,"right":"Correct.","wrong":"Not quite."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can…","items":["draw the symbols for NOT, AND, OR, NAND, NOR and XOR","complete truth tables for each gate","explain each gate in words","work out the number of truth-table rows","link logic gates to real situations"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"Logic gate","meaning":"A circuit that gives a binary output from binary inputs."},{"word":"Truth table","meaning":"A table listing every input combination and the output."},{"word":"Boolean","meaning":"A value that is TRUE (1) or FALSE (0)."},{"word":"Inverter","meaning":"Another name for a NOT gate."},{"word":"XOR","meaning":"Exclusive OR: one or the other, not both."}]},{"type":"sources","id":"sources","title":"Sources","items":["Raspberry Pi Foundation, Isaac Computer Science: logic gates","George Boole (1854), An Investigation of the Laws of Thought","Claude Shannon (1937), A Symbolic Analysis of Relay and Switching Circuits","BBC Bitesize, GCSE Computer Science: logic"]}]},"overlay":null}