This course includes resources provided by the following:
LEGO Education
CS-STEM Network from Carnegie Mellon University
EV3-Scratch documentation provided by Raphael Holzer
Joe Olayvar & Evelyn Lindberg in association with the Washington State Library
đ Click here to access the LEGO Education website.
đ Click here to access the EV3-Scratch documentation.
đ Click here to access the online EV3 course from CS2N.
đ Click here to access the LEGO Mindstorms EV3 Programming Basics document in its entirety.
âśď¸ Click here to access the entire LEGO Mindstorms EV3 YouTube playlist from the Washington State Library.
The Sensors lessons introduce the Touch, Ultrasonic, Gyro, and Color Sensors. You will gain an understanding of the appropriate sensors to use to accomplish different tasks.
âŹď¸ Install It
Before continuing, ensure that your computer has the EV3 Classroom app installed.
đ§ Build It
Before you continue, ensure that you have completed the following builds:
Color Cube (aka Cuboid)
Base Unit (aka Driving Base)
âĄď¸ Sense, Perceive, Plan, Act
đ Learn It
Carefully read and/or watch the instructional media and respond to the related questions.
If robots only do what they're told, how is it that one program can make the robot do different things every time it's run?
This robot is designed to stop at a specific distance from the wall. If it starts close to the wall, thatâs a short distance.
If it starts far from the wall, itâs longer.
The robot can tell when it reaches the wall using the Ultrasonic Sensor. And in both cases, thatâs how the robot knows when to stop. This type of behavior is what makes a robot a robot.
Sense, Perceive, Plan, Act
Sensors provide information about the world. The program uses that information to figure out when to stop. And then the robot acts accordingly. Sense, Perceive, Plan, Act (SPPA) summarizes the four critical capabilities that every robot must have in order to operate effectively:
SENSE: A robot needs the ability to sense important things about its environment, like the presence of obstacles or navigation aids.
PERCEIVE: Perception answers the question âWhat am I looking at?â This requires more than raw sensor data -- the robot needs to make sense of that data. Is the robot looking at the object it wants to pick up, or a wall in its way? Perhaps it needs to combine information from a few sensors to figure that out. Interpreting raw sensor data into useful understandings about the environment is called perception. Perception allows a robot to act in a way that is appropriate and safe within the environment.
PLAN: Based on its understanding of the world around it, the robot then needs to respond appropriately. Sometimes the strategy can be written in advance, like turning left at the first wall. Other times, the robot needs to figure out the right combination of moves on the spot. In either case, the robot will follow the program written by the human programmer that tells it what to do next, or how to figure that out for itself.
ACT: Finally, a robot must carry out the actions that the plan calls for. Robots will do exactly what you tell them to do. That may not be the same as what you meant! It is important to be very precise when telling robots what to do.
20 points
20
Question 1
1.
Discuss: Is a smartphone considered a robot? Why or why not?
20 points
20
Question 2
2.
Discuss: Think of another robot you use in your daily life. How does it meet each component of SPPA?
10 points
10
Question 3
3.
Which of the four robot components allows a robot to comprehend what they are looking at?
10 points
10
Question 4
4.
True or False: If given precise programming, robots will do exactly what you tell them to do.
đ Introduction with Touch Sensor
10 points
10
Question 5
5.
Why are sensors important to robots?
10 points
10
Question 6
6.
What is the advantage of Sensor Control over Sequential Commands?
âą Wait for Touch
In this lesson, you will program the robot to wait until its Touch Sensor is pressed before moving.
Robot Configuration: Touch Sensor Drive Base
For this chapter, the Touch Sensor Driving Base is required to complete the next sections of this chapter.
Touch Sensor Configuration
Touch Sensor Driving Base Build Instructions: https://drive.google.com/file/d/1wd4h4o8DigHtkspGUB4229av-zTBIVcn/view?usp=share_link
Step 1: Plug in Touch Sensor
Ensure that the Touch Sensor is plugged into port 1 on the robot.
Step 2: Start New Project
Create a new project and program.
Step 3: Add Move Forward Block
Add a âMove [forward] for 1 [rotations]â block to the program. This block will make the robot go 1 rotation when it runs.
Step 4: Add Wait Until Block
Now click on the light blue âSensorsâ palette, and add a Touch Sensor âwait untilâ Block above the âMoveâ block.
Step 5: Add Exit Block
Drag a âstop [and exit program]â block from the Control palette, and place it at the bottom of the stack.
Step 6: Rename Project
Rename the program as âWaitTouchâ.
Step 7: Download and Run Project
The robot waits for the Touch Sensor to be pressed, and then continues on to the Move command.
10 points
10
Question 7
7.
What is the function of the âwait until pressedâ block?
10 points
10
Question 8
8.
In the program below, the robot waits before it moves becauseâŚ
đŚ Try it! Already Pressed
What happens if youâre already holding down the Touch Sensorâs button when you start running the program?
What happens?
The robot moves immediately. The Wait Block detects that the sensor is âPressedâ and passes control to the Move Block.
âPressedâ simply means âthe button is in the pressed positionâ; it does not matter how or when it was pressed in!
đĄ Did You Know? EV3 Buttons
The 5 buttons on the front of the EV3 (not counting the Cancel button) can be used as Touch Sensors!
Try using the âwait until [center] button [pressed]â Sensor Block and setting the button selection to different buttons and running your program.
Once itâs running, press the middle button on the front of the EV3!
What happens?
The Wait Block now waits for the middle button on the EV3 to be pressed. The robot then moves.
đĄ Did You Know? How the Touch Sensor Works
When the Touch Sensor is pressed, it closes an electrical circuit, allowing current to flow.
If the Touch Sensor is released, the circuit is broken and no current flows.
The flow (or lack) of current is detected by the EV3, allowing it to determine whether the Touch Sensor is pressed.
đ§ Making Sense of Systems
Simple programs follow a simple rule: run commands in order from top to bottom and one at a time.
More complex programs might contain âWait Untilâ blocks that hold program flow at that spot until the condition is true. Conditions are statements made for the robot to evaluate something as either true or false. This Wait Until block in the program below checks if the Touch Sensor is pressed. The condition will be true if it is pressed, and false when it is not pressed. In this program, the robot will not move forward until the Touch Sensor has been pressed.
Programs pay attention to one block at a time. Their attention âflowsâ from block to block. Blocks in a sequence pass the flow down the line. Wait Until blocks hold the flow of the program at that point, and when the condition is true, the flow of the program continues.
Making a Mental Model
This mental idea of how the system works is called a âmodel.â Itâs like a tiny version in your head of how the real system operates.
This model explains sequence and Wait Until in a single idea, which helps everything make more sense.
It also helps you better predict what a new program will do since you know how it will work as a system. By having a mental model of how program flow works, you can learn to develop complex programs more easily.
Practice
1. Examine the program below. Describe what the robot will do, or, how the program will flow, after the program has started.
2. Examine the program below. Describe how the program will flow after the program has started.
Discuss
Consider the questions below, and then share your thoughts.
What are the benefits of creating mental models? Why does it help with understanding program flow? What else could you use mental models for?
Why is program flow an important concept to understand as a programmer?
20 points
20
Question 9
9.
Discuss: What are the benefits of creating mental models? Why does it help with understanding program flow? What else could you use mental models for?
20 points
20
Question 10
10.
Discuss: Why is program flow an important concept to understand as a programmer?
âĄď¸ Forward until Touch
Introduction: Forward until Touch
In this section, you will program the robot to move until its Touch Sensor is pressed. To do this, you will turn the robotâs motors on, leave them on while Waiting for the Touch Sensor to be pressed, then Stop them.
Step 1: Create New Project
Create a new project and program.
Step 2: Add Move Block
Begin by putting in a âstart moving [straight]â Block. This Block simply commands the motors to turn on and stay on until another command tells them to change.
Step 3: Add Wait Until Pressed Block
Next, add a Touch Sensor âwait until [pressed]â block.
Step 4: Add Stop Moving Block
To have the robot stop its motors, add a âstop movingâ block.
Step 5: Add Exit Block
Drag a âstop [and exit program]â block from the Control palette, and place it at the bottom of the stack.
Step 6: Rename Project
Rename the program as âForwardTouchâ.
Step 7: Download and Run Project
The motors turn on, the robot waits for the Touch Sensor to be pressed, and then turns the motors off.
đŚ Try it! Forward Until Release
The Touch Sensor âwait untilâ block can wait for the sensor to be "Released" as well as "Pressed".
What happens if you set it to ânot releasedâ and run it with an empty box holding down the sensor?
Note: When setting up the robot, have the obstacle placed firmly against the Touch Sensor so that it keeps it pressed in, as shown above.
10 points
10
Question 11
11.
True or False: The âreleasedâ option in the wait until block can only be used when the robot is in reverse.
đ Pseudocode
Big challenges are made up of small challenges. Try breaking it down into smaller pieces. Once you know how to solve parts of the problem, you can build on them and combine them to create your final solution. In programming, you can figure out a plan of what you want the robot to do, break it down into smaller parts, and build your program up from those pieces.
đ Iterative Process and Pseudocoding
What is the best way to develop a plan for your robot? Well, what is the best way to build a building? Is it best to build it all at once? While this may seem convenient, this method is prone to failure and makes it really hard to pinpoint where the failure took place. When you try to put too many parts together at once, the complexity of the system is too great. Too many little things can go wrong and it would be harder to find where the problem lies.
A better way would be to use an iterative process! You can start by building the foundation, test it to see if it is stable, then add the first floor, test it, and add another floor. It is important to test each after iteration to make sure there are not any problems. You can build the entire structure from the ground up, testing at each level to know that itâs stable. If something goes wrong, it is easy to know where the problem is because only one small part is added at a time.
This same methodology applies equally as well to programming. Take one small step and figure out how to solve it. Add it to the whole, and test the step. The best way to build a complex program is not all at once, but rather iteratively. This approach allows you to know that youâre building on a solid foundation of code! If something does go wrong, you know where to start looking to find the error.Â
In general, pseudocode is used to outline a program before translating it into code. Your programs get more complicated as you learn different robot behaviors and use sensors. Therefore, your pseudocode will become more detailed. But how detailed should it be? Letâs take a quick look at this example activityâŚ
First, it is important to break the steps down iteratively. This example shows the steps on how to catch a fish. The steps in the first column started off somewhat vague. But you can see that each column becomes more detailed. By the last column, the steps are very thorough with an iterative design and include specific details such as exact measurements, location, and directions.Â
Notice how multiple arrows are drawn from a single step in the âoriginalâ left column and branch out to the more detailed steps in the center and right columns. These arrows represent the expansion of the original, simple step into steps with more detail. Breaking down, or decomposing, your original steps to be more detailed, and again to be even more detailed, will help make a large task or problem much easier to accomplish! Try this activity on your own!
40 points
40
Question 12
12.
âď¸ Pseudocoding Activity: Everyday Task
Complete the following activity on the Formative canvas:
1. Select one of the following tasks.
Feed your pet
Take and post a selfie
Catch a fish using a rod and reel
Take a bus/subway/train to meet up with your friends
Add two 2-digit numbers by hand
2. In the first column, write down the steps you would need to do, to do the task you picked.
3. In the second columnâŚ
Break those steps down into more detail, like youâre explaining them to someone who has never done that task before.
Draw lines connecting each detailed step back to the instruction it came from in the left column.
4. In the third columnâŚ
Break those steps down into even more detail, like youâre explaining them to a 2nd-grader.Â
Draw lines connecting them to the steps in the middle column they came from.
Complete the following activity on the Formative canvas:
Use the same Pseudocoding Chart to write pseudocode for the Orchard Challenge from the Movement Unit!
2. In the first column, write down the steps you would need to do, to do the task you picked.
3. In the second columnâŚ
Break those steps down into more detail, like youâre explaining them to someone who has never done that task before.
Draw lines connecting each detailed step back to the instruction it came from in the left column.
4. In the third columnâŚ
Break those steps down into even more detail, like you âre explaining them to a 2nd-grader.Â
Draw lines connecting them to the steps in the middle column they came from.
20 points
20
Question 14
14.
Discuss: In what ways do you find pseudocoding helpful?
20 points
20
Question 15
15.
Discuss: Do you think everyoneâs pseudocode will look the same if trying to complete the same challenge? Why or why not?
đMini-Challenge:
đ§š Vacuum
Using a Touch Sensor, program the robot to touch all four walls of a room!
Using a 4âx4' table (with walls), have the robot start by facing toward a wall. Using a touch sensor, program the robot to move forward and touch ALL four walls.
đ A virtual version of this challenge is available HERE.
100 points
100
20 points
20
Question 17
17.
đ¸ Document It: Capture a screenshot (or multiple screenshots) of your completed program and upload or paste it onto the Formative canvas.
20 points
20
Question 18
18.
âŹď¸ Upload It: Upload your completed program.
đChallenge:
𦾠Arm Position
Challenge Overview
For this challenge, construct an arm with the Touch Sensor attached so that when the arm is fully upright the button on the Touch Sensor is pushed in. This might require adding an axle and another part to increase its "surface area".
Place the robot on a surface, and an object approximately 5 rotations length away from the robot. Starting with the arm in the âdownâ position, program the robot to raise its arm until the touch sensor is pushed in, move forward 5 rotations, lower the arm around the object, and then bring the object back to the starting location.
Challenge Details
Rules and Procedures:
The robotâs arm will be moved to a random position before running.
You must use the parts available to you to modify the Touch Sensorâs mounting so that it can detect when the EV3âs arm is in the âupâ position.
Try to do this with as few changes as possible.
When the âUpâ button on the front of the EV3 is pressed, the robot must raise its arm to the âUpâ position (1), move forward five rotations to the cargo (2), and bring it back to the original starting position (3).
Hints:
The trigger area on the Touch Sensor is small. You will probably need to build a âbumperâ or âextenderâ on the end of the Touch Sensor to make it detect the arm more reliably.
The EV3 core set includes two Touch Sensors. You can use one sensor for detecting the arm in the âUpâ position, and the other to detect the box.
You can also make a test run, then calculate âhow many times as farâ you need to move or turn to get the amount of movement you want, compared to a test run.
đ A virtual version of this challenge is available HERE.
100 points
100
20 points
20
Question 20
20.
đ¸ Document It: Capture a screenshot (or multiple screenshots) of your completed program and upload or paste it onto the Formative canvas.
20 points
20
Question 21
21.
âŹď¸ Upload It: Upload your completed program.
10 points
10
Question 22
22.
đ§ Retrieval Practice:
Summarize the content of this lesson. What topics, ideas, and vocabulary were introduced?