Computers and Digital Design Lesson Objectives: • Know that computers use logic (just as people do), which is manifested in programs • Know the functions of AND, OR, and NOT gates • Be able to construct basic circuits that make decisions Supplies: • Signs with AND, OR, NOT for students to wear around neck • Signs with the following inputs (1 of each for each group of 5 students): “The weather is nice.” “My friends want me to go.” “I have clean shorts.” “My parents are making me.” “I am hungry.” “I love corn dogs.” • Colored objects to represent ‘False’ (0’s) and ‘True’ (1’s). Could be red/green balls or index cards, etc. • Optional: actual circuit board to be wired up during lesson based on student-made inputs
Introduction: Electricity introduction is irrelevantAsk the students what they know about electricity. Many will have a lot to say about it, particularly if they just had the lesson on circuits. Brainstorm what they know that runs on electricity. If necessary, help them arrive at computers as objects that need electricity. Explain that computers run on programs, which are written by computer scientists to help computers make decisions. Programs work much the same way as you do when you make a decision – they take inputs, decide what is important, and make a decision based on the process of filtering the information. Today, we will talk about the logical steps you take to make a decision and show you how computer programs do the same thing. Part 1 – Truth Tables and Two-Input Circuit: Suppose they wanted to answer the question “Am I going to eat a corn dog?” Their answer would depend on whether the following two statements were true: “I am hungry” and “I love corn dogs.” NOTE: Explain that even if you don’t LOVE corn dogs, you like them enough to eat them should the need arise. Explain that sometimes computer scientists design programs by considering what the program should decide in all possible cases. Pass out the Truth Tables worksheet and have the students fill out the “Am I going to eat a corn dog?” section. You can help them get started by asking: Do you eat a corn dog if you love corn dogs and are hungry? Do eat a corn dog if you are hungry but do NOT love corn dogs? etc. Now introduce logic gates. Explain to students what AND, OR, and NOT gates are: • AND: (multiple inputs) will return TRUE if both inputs are true. • OR: (multiple inputs) will return TRUE if one or both inputs are true. • NOT: (single input) will return the opposite of the input Have the students as a large group use the terms AND, OR, and NOT to write a sentence describing whether they will eat a corn dog. They should come up with the following sentence:
“I will eat a corn dog if it I am hungry OR I love corn dogs.” This could also be written Explain that you are now going to make human circuits. Divide the class into groups of five students. Each student can be an input, logic gate, or output. The students should wear signs saying what they are (for example “I am hungry” or “OR”). Each student also should have two colored objects (balls or index cards). They can hold up the green/True card to represent an output of True, and a red/False card to represent an output of False. They point these cards at the next student(s). Only four students are really used for this circuit: the two inputs, one OR gate, and the output holder. You can likewise demonstrate the function of an AND gate using the example question, “Will I wear shorts? The inputs are “I have clean shorts” and “the weather is nice.” The output should correlate with the fact that they will wear shorts if they have clean shorts AND the weather it nice. Part 2 – Three-input Circuit: Now have the students consider the question “Am I going the fair today?” Have the students brainstorm inputs that might affect this, and choose three. These inputs should be true/false statements that would help them make the decision. If you like, you can mention that often one of the hardest parts of answering a question is deciding what kinds of things the answer depends on. A computer scientist must decide what inputs are needed to solve a problem, and then figure out how each input affects the answer. This is what they are doing now. Other scientists also do this: for example if you want to determine how fast a car will stop when you slam on the brakes, you would have to take into account how good your brakes are, whether there is water on the road, and how fast you were going originally. Final three inputs should be along the lines of: - The weather is nice (note that this is more straightforward than “it is not raining”) - My friends want to go with me - My parents make me **The inputs don’t need to be exactly the same as these, but try to make sure that at least one of them is an ‘overrider’-- for instance, the parents making them go will prevail regardless of other conditions. Optional: show them an actual circuit board of this circuit. Have the groups of five design write a truth table for the question “Am I going to the fair today?” and then have them design and build a human circuit. Depending on the progress of the groups, they can fill out their truth table and move right on to acting out their circuit, or you can bring the class together and go over the truth table first to make sure they are on the right track. Tutors can walk between groups during this time to answer questions and guide the groups as necessary.
Part 3 – Five-input Circuit: Now create a circuit based on the following question: Will I wear shorts to the fair? There is no truth table worksheet for this section. This is because the students should build on their earlier logic rather than starting over. As necessary, help them along the way with hints such as the following: • Write “Do I go to the fair AND do I wear shorts?” to break the problem into “Do I go to the fair?” (which they can already solve) and “Do wear shorts?” • Ask them how the “Do wear shorts” problem is different from the “Do I go to the fair” problem. Their outputs will combine at the end in a final AND gate, which will tell students whether or not to wear shorts and a t-shirt. This should only return ‘True’ if they are to go to the fair and wear shorts, and ‘False’ for any combination of not going to the fair and not wearing shorts. Summary: Return to idea of circuits representing computer programs, and how programs use logic like this to make decisions. Congratulate the students – they have built a fairly complicated program out of very simple parts: just AND, OR, and NOT gates. You can mention that programs used on computers are quite a bit more complex than the ones created today, but similar logic can be used.