Lesson Modules
Teaching Tips:
What else do people do in cars?
In order for an autonomous car to be effective, it has to juggle a lot of responsibilities. If time permits, allow students to collaborate and make a list of all the functions an autonomous car needs to perform.
What else can you make?
- play my favorite music
- use headlights in the dark
- use windshield wipers in the rain
- turn on the AC when it is hot
- park in a parking lot
Teaching Tips:
Question 1: Why would you need to turn the headlights on in your car?
To see in the dark.
Question 2: What do you think this code does?
Turns on the headlights of the car on and off.
At this point in the class, the teacher should read some of the answers aloud, and ask students for their thoughts.
Challenge:
What does this code do?
Show the class this program, but don't run it until several students guess what it does.
//www.robotlab.com/hubfs/Education.Robotlab.com/Autonomous%20Car/Scratch/lesson5exercise.sb2
Your parents do a lot of things when they drive, and our self-driving cars will need to do these things too. For this lesson we will be turning the headlights on and off!
(An LED is a kind of light. You have seen the RobotLAB autonomous car light up with many LEDs.)
Teaching Tips:
Here is the code: Lesson 5 Code
Here is a Step-by-Step guide to complete the code: Lesson 5 Code Instructions
Notice that it is very similar to the first lesson’s loops. While it should reinforce understanding of the basic programming concepts, it may also be a good way to find out which students are struggling.
Code solution:
Challenge solution:
- Make your list save the current value from the CDS sensor every half second.
- Write a function that deletes all the list data when the space key is pressed.
Note: Choosing 40 as the "dusk" value may not work for brightly lit classrooms. Adjust this number if needed.
Time to code!
1. Bluetooth | 2. Orchestra | 3. Scratch |
Connect your autonomous car to your dedicated computer via Bluetooth. | Open Orchestra and connect your robot to the program. | Open Scratch from Orchestra |
Code:
Write some code that makes your car turn on its lights if the brightness in the room goes below 30.
Step 1
Look at this code from the first lesson.
Step 2
Notice how the code you just saw is very similar. The blocks on the left turn the front lights on, and the blocks on the right turn the front lights off.
How can you tell if it is dark outside? You can see it with your eyes! How can your RobotLAB Autonomous Car tell if it’s dark?
Using a sensor called a CDS sensor.
Step 3
Write some code that makes your car turn on its lights if the brightness in the room goes below 30 (make it a variable). Here are some blocks you can choose from:
Hint:
Step 4
It's much easier to troubleshoot your code when you can see the results from the sensor. But how can you log the value or make any sense of it if it's constantly changing?
- make several variables
- write the values down
- make a list in Scratch
- I don't know
Try this:
1. Click "Make a List"
2. Name it something like "light" or "light data"
3. All these new blocks will appear!
4. And you'll see an empty list in the top left corner of the screen.
Challenge
- Make your list save the current value from the CDS sensor every half second.
- Write a function that deletes all the list data when the space key is pressed.
Teaching Tips:
Question 1: Check the concepts you understand.
This is the students' self-assessment of their understanding of the material. You will see a bar graph once all the poll answers are submitted
Question 2: What does the CDS sensor do?
It measures the level of light in the area.
Question 3: Why was the Forever loop necessary for the program?
It is necessary because we want the program to run over and over, not just one time.
Question 4: What was the coolest thing you learned today?
Any answer will do here. If time permits have a short discussion with students about their answers.
At this point in the class, the teacher should read some of the answers aloud, and ask students for their thoughts.
Don’t worry, this isn’t for a grade, it’s just so your teacher can check the classes’ understanding.
- CDS sensor
- Greater-than
- Less-than
- If loop
- Forever loop
- Variable