Have you ever seen an autonomous car?
How did your teacher control the car?
Autonomous cars use sensors to “see” their environment. People use sensors too. We have eyes that see, noses that smell, and ears that hear. But just seeing isn’t enough. The things we see, hear, and smell help us make decisions. Your eyes don’t tell your body to stop when you reach the finish line at a race, your brain does!
Your autonomous car has a brain that it uses to understand the information from the sensors. Instead of a picture, sound or smell, the car gets a number. When a race car is speeding down the track, the driver inside knows when to turn and when to stop due to the information from his sensors. Someone taught him how to interpret the information her gets from his sensors. Autonomous cars need to learn how to drive too. We “teach” them what the numbers they sense mean using code.
Here is an example of a tooth-brushing algorithm:
Put toothbrush under faucet
WAIT 1 second
Take toothbrush out of faucet
Squeeze toothpaste onto toothbrush
Put toothbrush on teeth
While (teeth = dirty)
Move brush left
WAIT 0.5 second
Move brush right
Before we make an autonomous car, let’s make a normal car. At the end of this lesson, you will be able to drive this car yourself using your PC computer!
|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
The first thing your car needs to do is stop and go. What algorithm do you need to write to make the robot do that?
Which block(s) do you think we should use in order to make the robot move forward when you press the “A” button?
Hint: you can do it in just 2 steps
If you don’t get it, try again using only these blocks:
Knowing what you know about making the car go, what do you think you’ll need to do to make the car stop?
Which block(s) do you think we should use in order to make the robot move backward when you press the “A” button.
Make a guess, code it, and see what happens to Scratch!
Hint: The numbers after L and R are the power levels for the wheels on the left and right sides.
Next, we should get the car to go left and right.
Which block(s) do you think we should use in order to make the robot turn left when you press the “A” button.
Try it out on the Scratch and see how it works!
Hint: Try clicking this block and look at your options.
Knowing what you know about making the car turn left, what do you think you’ll need to do to make the car turn right?
Which block(s) do you think we should use in order to make the robot turn right when you press the “A” button.
Make a guess, code it, and see what happens!
Hint: If turning left is a negative angle, turning right must be a positive angle.
To make your car fully functional, you'll have to assign a different key for each function (forward, back, left, right). Try:
W - forward
A - left
S - back
D - right
Don’t worry, this isn’t for a grade, it’s just so your teacher can check the classes’ understanding.
- If loop
- Forever loop