Teaching Middle and High School Students How AI Works
A computer science and robotics teacher explains how he teaches the science behind machine learning with a templated lesson format.
Your content has been saved!
Go to My Saved Content.Artificial intelligence is the subject of endless debates in schools across the country. As a middle school computer science teacher, I believe that it’s not enough for students to simply know how to use AI; they also need to know how it works. By understanding the underlying mechanics, students are better prepared to effectively and responsibly utilize AI in the real world.
For this reason, I teach AI literacy in my classroom. Each week, my students watch, read, and create with AI.
Watch: Students watch a short video showing how AI is impacting all sorts of industries and applications, including sports, NASA missions, medicine, art, and music.
Read: Next, students read an informational article about the same topic and answer reflection questions. The reading builds grade-level literacy skills. Questions are intentionally aligned with state reading standards for informational text, demonstrating how computer science class can support cross-curricular learning goals.
Create: Finally, students put their learning into practice. Each week concludes with hands-on activities that pull back the curtain on how AI models are trained and built.
To prepare for teaching about AI, I tap into a host of free resources and also attend professional development webinars. Some great facilitators include the Raspberry Pi Foundation, the Scratch Foundation, and the Computer Science Teachers Association. The website The Hour of AI has an expansive library of activities and lessons. CodeAI has free lessons as well as weekly, quarterly, semester-long, and yearlong courses that are categorized by grade level.
Teaching About Machine Learning With the Watch, Read, Create Model
I created a three-part unit about machine learning, which also has an optional capstone project. Each part includes something to watch, read, and create.
Part 1: AI and the Ocean
- Watch: Students view a four-minute YouTube video about how the nonprofit group the Ocean Cleanup is using AI to effectively reduce plastic pollution that otherwise harms wildlife and ecosystems.
- Read: Students look over a press release with more information about the Ocean Cleanup’s efforts to remove marine trash.
- Create: Students learn about machine learning models and help clean trash from the ocean, via CodeAI’s “AI for Oceans” activity.
Students explore how training data enables a machine learning model to classify new data. First, students classify objects as either “fish” or “not fish.” Then, students expand their training data set to include other sea creatures that belong in the water. In the second part of the activity, students choose their own labels to apply to images of randomly generated fish. The point is to ensure that the model can eventually understand the difference between marine life and trash.

Part 2: AI and Wearables
- Watch: Students watch a brief NBC News segment about new, innovative AI technologies that are being integrated into smart glasses. The segment also addresses privacy concerns that come with smart glasses.
- Read: Students review an article about previous attempts to create color-filtering lenses for people with color blindness and how those attempts haven’t been very successful. The article goes on to explain how AI might present a new path forward for people with color blindness.
- Create: I task students with creating a prototype of glasses for colorblind people.
Students move to Scratch to program their own machine learning model. Using the video sensing extension, they teach their program to recognize different colors by holding up colored objects to the camera and classifying them. Once trained, the program identifies the colors in real time.
Students then program the model onto a pair of virtual glasses. When an object is held up to the camera, the glasses on the screen identify and verbalize the color name aloud. As someone who’s colorblind, I find that this project hits close to home—I’d love a pair of these glasses in real life.
Part 3: Self-Driving Cars
- Watch: My students are big fans of YouTuber Mark Rober, so I have them watch a fascinating video of his titled, Can You Fool a Self-Driving Car?
- Read: Hyundai has a solid primer on how self-driving cars work. Students answer questions, based on this reading, that test their understanding of this real-world technology.
- Create: Students bring machine learning into the physical world by designing autonomous traffic lights with VEX V5 Robotics.
The VEX V5 robot kits enable students to design a mini-car that has front-wheel drive with two motors and an AI vision sensor. Students train the AI sensor so that it can recognize colored traffic conditions: red, yellow, and green. Similar to the portion of the unit with color-blindness glasses, students must teach the color data to the AI sensor before writing the conditional logic. Once trained, the robot makes autonomous driving decisions based on which color the sensor detects. Red stops the motors, yellow sets motor velocity to 50 percent, and green sets motor velocity to 100 percent.

Optional Part 4: Capstone Project
- Watch: Class begins with a video that explains how Alexa, Siri, Google, and other AI assistants use speech recognition. The video details how these devices take a person’s words and turn them into commands.
- Read: Students read an article about the voices of the different AI assistants. Students learn about the text-to-speech technology that’s built into these devices.
- Create: Putting all of this information together, students are challenged to create their own AI assistant device with the programming platform Scratch.
Modeled after Amazon’s Alexa and the iPhone’s Siri, a student’s AI assistant should be able to verbally respond to the following questions and prompts:
- What is its name?
- What time is it?
- What’s the date?
- Tell a joke.
- Tell a random fact.
- Translate a word or phrase from English into another language of the user’s choosing.
- Say “I do not understand” if it is does not know the answer to the question.
By combining real-world media, cross-curricular reading, problem-based programming, and physical robotics, middle school students finish my class with a foundational understanding of AI. With this knowledge, students are able to evolve from passive consumers of AI into critical thinkers and creators.
