Blog: Try an Hour of Code with BSD Online
Written by Eva Yeung of BSD Education

For this year’s Hour of Code, challenge your students with a special BSD Hour of Code project: Build your own AI Smart Car! In this fun project, you and your students have the opportunity to develop the main AI (artificial intelligence) logic for a self-driving car, using JavaScript programming.




The project begins with a parked car that, through the project, students need to make reach a destination target without crashing or getting a ticket. The objective is to gradually build up the logic of the car so that it can automatically start, shift to drive, gain enough speed, not go over the speed limit, stop at red lights and take correct turns. Students will be challenged to apply their Computational Thinking skills to deconstruct the obstacles at hand and come up with a set of algorithmic instructions in JavaScript to navigate their car to the target destination.
Find the project solutions below
.
Key JavaScript concepts used:
- Variables
- Conditional statements
- Functions
Before starting the project, engage your class by initiating a discussion by asking:
- What do you already know about AI — Artificial Intelligence?
- Can you predict how robots will change our world?
- What are the advantages and disadvantages of self-driving cars?
- Which parts of school do you think robots will take over first? What are the benefits and risks?
- What does AI mean for jobs in the future?
- Can robots be creative? (Watch “Can robots be creative?” by Gil Weinberg on TedEd)
If you want to take this project further, you can learn more about AI by using these video resources:
- “What is Artificial Intelligence (or Machine Learning)?” by HubSpot (Video duration: 6 minutes and 14 seconds)
- “Machine Learning & Artificial Intelligence: Crash Course Computer Science #34” by CrashCourse (Video duration: 11 minutes and 50 seconds)
Project Solutions
Step 1:
Objective: get the car started:
Solution: engineOn(); drive();
Step 2:
Objective: get the car to speed up:
Solution: + accelerate();
Step 3:
Objective: avoid going over the speed limit:
Solution: if speed >= limit cruise();
Step 4:
Objective: stop at red light and go at green light.
Step 5:
Objective: turn right at next road with junction
Solution: if atConjunction(): turn(nextDirection)
Interested in learning more about Coding? Email Eva at ey@bsd.education or read more articles here.
Leave a Reply