- Students will be able to explain what a programmer does.
- Students will be able to explain a bug.
- Students will be able to use basic programming language to move a “robot” forward, spin, and jump.
- Programmer: A person that writes the code (language) that tells the computer what to do.
- Code: The language that programmers create and use to tell computers what to do.
- Sequence: Sequence is one of three basic flow control structures in programming, and is the very first concept a student must understand when learning to code. Also known as the order of events, a computer will execute commands exactly in the order or sequence they are written. As a programmer, it is important to make sure that the commands given to a computer are in the right sequence, otherwise, a program might not run as expected.
- Bug: An error or mistake in your code.
- Debugging: The process of finding and correcting a mistake in your code.
Direct Instruction (I do) 15 minutes
Begin by introducing the concepts for lesson (programmer, code, sequence). Give the definition of each on the board or chart paper to have available for students to refer to during the class activity. *Optional: Include visuals to go with terms or have anchored in the room for later reference.
T (ASK): “Who do you think is smarter, you or a computer? Explain your answer giving reasons.”
Give students 1 minute to turn and discuss with their partner. Call on 3 quiet hands to share their answers.
“People are actually much smarter than computers. In fact, computers can’t do anything without the people who are telling them what to do. The people who tell computers what to do are called programmers.”
Record on the board or chart paper: A programmer is a person who uses code, or programming language, to tell a computer what to do. (attach visual of a person with a computer)
T: “Can you share an example of something a programmer would make?”
Call on 3 quiet hands to share their answers. (games, other programs you use at school, cars, airplanes, space ships, iPads, phones) Most students will use games as the example, but try to help them make connections to other things programmers write code for.
“All of the games, programs, and things you just talked about programs created by programmers who tell the computer what to do. Programmers use a special language called code, to create these things. Raise your hand if you think it would be fun to create a game or program a space ship someday.”
Record on the board or chart paper:
Code is the language that programmers use and create to tell computers what to do.
T: “Programmers use the code that they write to tell the computer EXACTLY what to do. They have to tell the computer what to do in the right order, or it won’t work correctly. This is also known as the order of events. A computer executes the directions (commands) exactly in the order or sequence they are written.”
ASK: “Think about washing your hands: We know that you need to put soap on your hands, scrub, rinse, and dry them. What if we did it in a different order, like scrub, rinse, soap, dry? Would our hands be clean and dry at the end?”
“Sequence makes the computer correctly carry out the directions to make the program work.”
Record on the board or chart paper: Sequence- the order that a computer executes the directions written by the programmer. The computer will follow the order or sequence exactly as they are written.
Guided Practice Activity: Beginner: Second Grade
Students will act as programmers and apply basic knowledge of programming language and sequence to command a robot to move forward and jump.
Time: 20-25 minutes
- Whiteboard, markers, smart board or writing area that everyone can see.
- It is ideal to have another adult be the robot, but a student would be another option if you don’t have a TA, assistant or room parent.
- Floor space for the robot to move and for students to sit.
Important! All robots must be told when to start either with a high five or by saying “start” together as a class. Also, most robots are noise sensitive and can’t function if there is a lot of noise in the room.
Have students seated on the floor or rug area. Explain that another teacher, student, or parent is a robot, and that they need instructions from a programmer. Review that computers aren’t as smart as people.
Explain that we want to program the robot to walk forward and jump. Demonstrate this for them.
T: (Ask) “How do we walk?” (Acceptable response: with our feet, with our legs) Discuss why we use our feet to walk. Ask everyone to show you their right foot and left foot. Explain that we have to walk “right, left, right, left” so that we don’t end up in the splits. “We need commands to tell our robot to move their right foot and left foot, because our robot won’t know what to do without instructions.”
Write the commands on the board, and explain why they look that way (circle to indicate which foot should stay still and arrow to indicate which leg to move).
T: (Ask) “What should we tell our robot to do first?” (Either right foot or left foot forward) Write the program under “our code” with all commands separated by commas. Ask for the second move.
T: (Ask) “Is this enough steps? How can we tell?” (students should want to test the code)
Choose a student to high-five the robot to activate it. The robot will take two steps forward and crash, then you can rewind it.
T: (Ask) “Oh no! Our robot crashed! Why did it crash?” (Because it needs more code to complete the program)
Based on how big the steps are, determine how many more steps need to be taken. Ask students how many more steps are needed. “If we’ve taken 2 steps and we’re half way there, how many more do we need?”
Repeat as many times as needed to complete the correct number of steps.
T: After the robot is getting to the correct spot, ask “Now what do we want our robot to do?” (Turn around) “How are we going to tell it to turn around? What shape do we make when we spin?” (a circle) “And which directions can we spin? "(Left or right)
“Let’s use a circle and an arrow pointing right, to tell our robot to turn right, and a circle and an arrow pointing left to tell our robot to turn left. Now, which direction do we want our robot to turn?” (either left or right) Write the code, then test it again.
T: Instruct the “robot” ahead of time to do a complete turn instead of half a turn. When the robot does the turn incorrectly, ask, “Uh oh! What happened?” (Our robot turned too much) “Yes, we made a mistake. When you’re programming is it okay to make mistakes?” (Yes!) “That’s right! A mistake in your code is called a bug! And when we fix bugs in our code we are debugging.”
Open up a discussion about doing a ½ turn rather than a whole turn. Use the opportunity to tie in to fractions, positions on a clock, or degrees of rotation. Be sure to make the change in your code by adding, “1/2 turn” next to your spin command. (pictured above) When the code is corrected, continue.
When it is time to jump, ask the students, “How many legs do we use to jump?” (they should say 2) Use 2 arrows pointing up to mean jump. Write the command and then add it to the code.
Complete the program and run it.
Celebrate! YOU’RE ALL PROGRAMMERS!
Optional: If you have time, you can ask for a “replacement robot”, because yours is almost out of batteries. Choose a student to become the robot and run the program.
Check for Understanding / Informal Assessment
Time: 10 minutes
Ask the class each question. Give 30 seconds for students to think and then turn to share with their partner for 1 minute (Think, Pair, Share). Record answers on chart paper to hang for later reference.
Review programmer, programming language, and sequence.
- What is a programmer?
- What is an example of a program?
- What do we call the language that programmers use to communicate with computers?
- How do computers or computer programs work?
- What happens if we give the computer directions in the wrong order?
- What happens if a programmer forgets a step in their directions?
- What is a sequence? Why is sequence important?
Smeeborg Sequence Sector 1.1-1.5 "1,2,3, Roll" and 1.6-1.10 "Buggy Basics"