Curriculum pack

Game Design with Microcontrollers, 6 weeks

Reaction games, dice, a memory game, Pong and Snake, on real buttons, LEDs and screens. Students learn the game loop, state, randomness and collisions, then design and playtest a game of their own.

  • Grades 8 to 12
  • 6 weeks
  • Three class periods a week, about 45 minutes each.
  • Teacher answer key included

Before this pack: Arduino Programming, or comfort with variables, if, loops and millis().

The pack at a glance

WeekTopicGraded workStandards
1The game loop and input1 lesson with checkpoints2-AP-12, 3A-AP-16
2State and randomness1 lesson with checkpoints2-AP-11, 2-AP-12, 2-DA-08
3A memory game1 lesson with checkpoints2-AP-12, 2-AP-13
4Drawing on a screen1 lesson with checkpoints3B-CS-02, 2-AP-16
5Pong: movement and collisions1 lesson with checkpoints3A-AP-16, 2-AP-17
6Snake, and a game of your own1 lesson with checkpoints, 1 auto-graded check3A-AP-13, 2-AP-15, 2-AP-17

Week by week

Each week has a lesson plan, objectives, the questions to ask, the graded work and the vocabulary. The minutes are a guide.

Week 1

The game loop and input

Read the buttons, update the game, draw the result, and do it again, fast.

Learning objectives: students will be able to

  • Describe a game loop as input, update and output
  • Measure a reaction time with millis()
  • Decide a winner fairly from two inputs

Lesson plan

  1. Warm up (5 min): play Reaction duel in pairs.
  2. Lesson (25 min): Project: a reaction timer.
  3. Explore (15 min): read the duel sketch. How does it decide who pressed first?
  4. Close (5 min): draw the game loop as three boxes.

Ask the class

  • Why does a fair reaction game wait a random time before the light?
  • What should happen if a player presses before the light comes on?

Graded work

  • Project: a reaction timer: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: Reaction duel · Reaction timer

Vocabulary

Game loop
Read input, update the game, draw it, and repeat.
Input
What the player does: a button, a knob, a stick.
Latency
The delay between an action and the response.
Random
Unpredictable, so the player cannot guess.

Standards: 2-AP-12, 3A-AP-16

Week 2

State and randomness

A die that tumbles and settles, and a program that always knows which state it is in.

Learning objectives: students will be able to

  • Use random() and explain why a seed matters
  • Write a program as named states with transitions
  • Show a number on a seven-segment display

Lesson plan

  1. Warm up (5 min): roll Electronic dice twenty times and tally the results.
  2. Lesson (25 min): One variable that says where you are.
  3. Build (15 min): add a state to the dice: a "ready" pattern while waiting.
  4. Close (5 min): is your tally evenly spread? Why might it not be after only twenty rolls?

Ask the class

  • Why would a die that starts from the same seed every time be a bad die?
  • What are the states of the electronic dice, and what moves it between them?

Graded work

Projects to open: Electronic dice · OLED dice

Vocabulary

State
Which stage a program is in right now.
Transition
A rule that moves the program to another state.
Seed
The starting value for a sequence of random numbers.
Seven-segment display
Seven bars that light to show a digit.

Standards: 2-AP-11, 2-AP-12, 2-DA-08

Week 3

A memory game

Simon: a growing sequence stored in an array, played back and checked press by press.

Learning objectives: students will be able to

  • Store a growing sequence in an array
  • Compare player input against the stored sequence
  • Give feedback with light and sound

Lesson plan

  1. Warm up (5 min): play Simon on the ring for two minutes.
  2. Lesson (30 min): Project: a memory game.
  3. Extend (10 min): change the speed as the sequence grows.
  4. Close (5 min): what is the longest sequence the array can hold?

Ask the class

  • Why does the game keep the whole sequence instead of only the newest color?
  • How could you make the game harder without changing the rules?

Graded work

  • Project: a memory game: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: Ring Simon · ESP32-C3 Simon

Vocabulary

Sequence
An ordered list of steps.
Index
The position of an item in an array, counted from zero.
Feedback
What the game shows or plays in response to the player.
Difficulty curve
How a game gets harder as it goes.

Standards: 2-AP-12, 2-AP-13

Week 4

Drawing on a screen

Pixels, coordinates and frames on a 128 by 64 OLED over two wires.

Learning objectives: students will be able to

  • Place shapes and text on a display using x and y coordinates
  • Redraw a scene as frames
  • Explain why a game repaints only what changed

Lesson plan

  1. Warm up (5 min): where is pixel (0, 0) on the screen?
  2. Lesson (25 min): A screen on two wires.
  3. Build (15 min): draw your initials and bounce a ball.
  4. Close (5 min): how many pixels does a 128 by 64 screen have?

Ask the class

  • Why do games often redraw only the part of the screen that moved?
  • Where is the origin on this display, and which way does y grow?

Graded work

  • A screen on two wires: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: OLED on an ESP32-C3 · OLED on an Uno

Vocabulary

Pixel
One dot on a screen.
Coordinates
The x and y position of a pixel.
Frame
One complete drawing of the screen.
Frame rate
How many frames are drawn each second.

Standards: 3B-CS-02, 2-AP-16

Week 5

Pong: movement and collisions

A ball with a velocity, a paddle on a thumb stick, and the math of a bounce.

Learning objectives: students will be able to

  • Move an object with a velocity each frame
  • Detect a collision between a ball and a paddle
  • Change the bounce angle based on where the ball hits

Lesson plan

  1. Warm up (5 min): play OLED pong. What decides the angle of a bounce?
  2. Lesson (25 min): Project: a console.
  3. Build (15 min): make the ball speed up after every fifth hit.
  4. Close (5 min): write the collision test in plain English.

Ask the class

  • How does the game know the ball has hit the paddle?
  • Why does the bounce angle depend on where the ball strikes the paddle?

Graded work

  • Project: a console: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: OLED pong · Pong console · OLED pong on an ESP32-C3

Vocabulary

Velocity
How far an object moves each frame, and in which direction.
Collision
Two objects touching or overlapping.
Bounding box
The rectangle around an object, used to test collisions.
Playtest
Watching real players try a game to find what to fix.

Standards: 3A-AP-16, 2-AP-17

Week 6

Snake, and a game of your own

A snake that grows on two LED matrices, then a game each student designs, builds and playtests.

Learning objectives: students will be able to

  • Represent a growing snake as a list of positions
  • Design a game with clear rules, a goal and a way to lose
  • Playtest with classmates and improve from their feedback

Lesson plan

  1. Warm up (5 min): play Snake on two matrices. How does it remember where the body is?
  2. Lesson (1 period): Project: the game is yours.
  3. Build (2 periods): design and build a game to a one-page brief: rules, controls, goal, how you lose.
  4. Playtest (1 period): swap links with another student, play, give one change, and make it.

Ask the class

  • How does Snake know when the snake has bitten itself?
  • What did your playtester find that you had not noticed?

Graded work

  • Project: the game is yours: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Rebuild Snake on two matrices and hand it in running. Assign Snake on two matrices as a template and add these checks. Our own build passes every one:
  • Check: The game starts and says so (the serial monitor prints a line matching /snake on two MAX7219/ within 3 s).

Projects to open: Snake on two matrices · Snake · Stacker · Console

Vocabulary

Game design
Deciding the rules, goal and feel of a game.
Win condition
What a player must do to win.
Iteration
Changing a design after testing it, then testing again.
Brief
A short description of what a project must do.

Standards: 3A-AP-13, 2-AP-15, 2-AP-17

For teachers only

Teacher answer key

Answers to every question, how to grade each week, and the mistakes worth watching for. It opens for a signed-in teacher with a class and the class tools, and is never sent to a student.

Sign in with your teacher account to see the answer key.

Standards alignment

Each code is quoted from the published standard and cited only where the week gives students that practice. Mokxi is not certified by any standards body; check these against your state’s adoption.

CodeFrameworkThe standardWeeks
2-AP-12CSTADesign and iteratively develop programs that combine control structures, including nested loops and compound conditionals.1, 2, 3
3A-AP-16CSTADesign and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions.1, 5
2-AP-11CSTACreate clearly named variables that represent different data types and perform operations on their values.2
2-DA-08CSTACollect data using computational tools and transform the data to make it more useful and reliable.2
2-AP-13CSTADecompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.3
3B-CS-02CSTAIllustrate ways computing systems implement logic, input, and output through hardware components.4
2-AP-16CSTAIncorporate existing code, media, and libraries into original programs, and give attribution.4
2-AP-17CSTASystematically test and refine programs using a range of test cases.5, 6
3A-AP-13CSTACreate prototypes that use algorithms to solve computational problems by leveraging prior student knowledge and personal interests.6
2-AP-15CSTASeek and incorporate feedback from team members and users to refine a solution that meets user needs.6
For your class

Everything this pack needs, in one class

A roster with a six-character join code, the week’s lesson or starter handed to every student, checks that grade each hand-in, a live wall of everyone’s work and this answer key. Classes come with Pro and the Teacher plan, and the free 30-day trial has every tool.

Student privacy: what is kept, and what never is

Questions teachers ask

How do I assign a week’s graded work?

From your class page, choose Assign work, then A lesson, and pick the lesson by name. Each student’s hand-in arrives with the steps they completed. For a week with checks, assign the project as a template, open Checks under the assignment, and add the checks listed for that week.

Who can see the answer key?

Only a signed-in teacher who owns a class and has the class tools: Pro, the Teacher plan, a school plan or the free 30-day class trial. The key is never part of the page a student loads, and a student account cannot open it.

Do students need accounts?

Not to open the projects and lessons from a link. To hand work in through a class they need an account, because a class is a roster, and a student under 13 joins only with the consent your school gives under COPPA.

Can I change the order or the lessons?

Yes. Each week stands on the ones before it, but you can skip, reorder or swap any lesson, and every project opens in the editor for you to change before you assign it.

Teach it with a class

Start the free 30-day class trial: one class of up to forty students, every class tool and the answer keys, with no card.