Curriculum pack

Arduino Programming, 9 weeks

From the first blink to a finished project: outputs, inputs, variables and conditions, timing without delay, analog input, PWM and sound, serial, and a project of the student’s own. Real C++, compiled in the browser.

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

Before this pack: Intro to Electronics, or the first two weeks of it: a complete circuit and why an LED needs a resistor.

The pack at a glance

WeekTopicGraded workStandards
1Blink: the first program2 lessons with checkpoints, 2 auto-graded checks2-AP-12, 2-CS-02
2More outputs, in order2 lessons with checkpoints2-AP-10, 2-AP-12
3Inputs: buttons and pull-ups2 lessons with checkpoints, 2 auto-graded checks2-CS-02, 2-AP-12
4Variables, decisions and loops3 lessons with checkpoints2-AP-11, 2-AP-12
5Timing without delay2 lessons with checkpoints2-AP-12, 2-AP-17
6Analog input2 lessons with checkpoints, 1 auto-graded check2-CS-02, 2-DA-08
7PWM, light and sound1 lesson with checkpoints, 1 auto-graded check2-AP-12, 2-AP-16
8Serial and functions3 lessons with checkpoints2-AP-14, 2-CS-02
9Final project3 lessons with checkpoints3A-AP-13, 3A-AP-17, 2-AP-17, 2-AP-15

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

Blink: the first program

Two wires from an Uno to an LED, then setup(), loop(), pinMode, digitalWrite and delay.

Learning objectives: students will be able to

  • Name what setup() and loop() are for
  • Set a pin as an output and drive it high and low
  • Change a delay and predict the blink rate

Lesson plan

  1. Warm up (5 min): run First blink. Read the sketch aloud, line by line.
  2. Lesson (15 min): Make it blink with an Uno. Students wire it themselves.
  3. Lesson (20 min): Blink: the first program. Change the timing and fix a compile error on purpose.
  4. Close (5 min): write the blink pattern for SOS in plain English.

Ask the class

  • What happens if you leave out pinMode(13, OUTPUT)?
  • How many times a second does the pin change if the LED blinks five times a second?

Graded work

  • Make it blink with an Uno: a lesson whose 4 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Blink: the first program: a lesson whose 5 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Rebuild First blink on your own breadboard, wired from pin 13, and hand it in. Assign First blink as a template and add these checks. Our own build passes every one:
  • Check: Pin 13 blinks once a second (pin 13 on uno1 toggles every 1 s, within 50 ms, watched for 4 s).
  • Check: The LED lights (the LED led1 is lit at 250 ms).

Projects to open: First blink

Vocabulary

Sketch
An Arduino program.
setup()
Runs once when the board starts.
loop()
Runs over and over, forever, after setup().
Output pin
A pin the program drives high (5 V) or low (0 V).

Standards: 2-AP-12, 2-CS-02

Week 2

More outputs, in order

Two lamps taking turns, then a traffic light sequence.

Learning objectives: students will be able to

  • Drive several outputs from one program
  • Write a sequence as steps with timing
  • Read a sequence from serial output to debug it

Lesson plan

  1. Warm up (5 min): what order do traffic lights go in? Write it as a list.
  2. Lesson (20 min): Two outputs, taking turns.
  3. Lesson (20 min): Five outputs and a sequence, the pelican crossing.
  4. Close (5 min): flowchart the crossing on paper.

Ask the class

  • Why does the WAIT lamp light instantly, even while the sketch is inside a long delay?
  • With three pins and shift registers, how could you drive many more lamps?

Graded work

  • Two outputs, taking turns: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Five outputs and a sequence: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: Traffic light

Vocabulary

Sequence
Steps that happen in a set order.
Flowchart
A drawing of a program’s steps and decisions.
delay()
Stops the program for a number of milliseconds.
Millisecond
One thousandth of a second.

Standards: 2-AP-10, 2-AP-12

Week 3

Inputs: buttons and pull-ups

Reading a pin, why pressed reads low, and turning a press into a toggle.

Learning objectives: students will be able to

  • Read a button with digitalRead and INPUT_PULLUP
  • Explain why an input must never float
  • Tell a level from an edge, and debounce a press

Lesson plan

  1. Warm up (5 min): open Button and LED. Hold the button. Why does it read LOW?
  2. Lesson (20 min): Reading a pin, and the pull-up.
  3. Lesson (20 min): Press once for on, once for off.
  4. Close (5 min): explain bounce in one sentence.

Ask the class

  • Why does the button read LOW when it is pressed?
  • Why can one press of a real button be counted several times?

Graded work

  • Reading a pin, and the pull-up: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Press once for on, once for off: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Rebuild Button and LED: a button on pin 2 to ground, an LED on pin 13. Hand it in. Assign Button and LED as a template and add these checks. Our own build passes every one:
  • Check: The LED is off before anyone presses (pin 13 on uno1 reads LOW at 400 ms).
  • Check: The LED goes out again when the button is let go (after pb1 is pressed at 500 ms for 300 ms: pin 13 on uno1 reads LOW at 1100 ms, by 1100 ms).

Projects to open: Button and LED

Vocabulary

Input pin
A pin the program reads as high or low.
Pull-up resistor
A resistor that holds an input high when nothing pulls it low.
Floating
An input connected to nothing, which reads at random.
Debounce
Ignoring the extra edges a mechanical switch makes.

Standards: 2-CS-02, 2-AP-12

Week 4

Variables, decisions and loops

The C++ underneath: types and sizes, if and else, and a loop over a list.

Learning objectives: students will be able to

  • Create variables with suitable types and clear names
  • Write an if and else that decides from a value
  • Loop over a list with for

Lesson plan

  1. Warm up (5 min): what is the biggest number a byte can hold?
  2. Lesson (15 min): Variables have a size.
  3. Lesson (15 min): One branch runs.
  4. Lesson (15 min): A loop over a list.

Ask the class

  • What happens when a byte variable holding 255 has 1 added to it?
  • Why does only one branch of an if and else ever run?

Graded work

  • Variables have a size: a lesson whose 7 steps tick against the running circuit. Assign it from your class page under A lesson.
  • One branch runs: a lesson whose 7 steps tick against the running circuit. Assign it from your class page under A lesson.
  • A loop over a list: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Vocabulary

Variable
A named place that holds a value.
Type
What kind of value a variable holds, and how big it can be.
Condition
A test that is true or false.
for loop
Repeats a block a counted number of times.

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

Week 5

Timing without delay

Ask the time instead of waiting for it: two rates at once, and a board that still listens.

Learning objectives: students will be able to

  • Use millis() to run two things at different rates
  • Explain why delay() makes a program unresponsive
  • Keep a timestamp for each thing that repeats

Lesson plan

  1. Warm up (5 min): try to blink two LEDs at different rates with delay alone.
  2. Lesson (20 min): Two rates at once, without delay.
  3. Lesson (20 min): Blinking and listening at the same time.
  4. Close (5 min): name one real device that must never block.

Ask the class

  • Why can delay() not blink two LEDs at two different rates?
  • Why does millis() keep counting while a delay() is running?

Graded work

Vocabulary

millis()
Milliseconds since the board started.
Blocking
Code that stops everything else while it waits.
Timestamp
A saved time, to compare against later.
Responsive
Reacting to input quickly.

Standards: 2-AP-12, 2-AP-17

Week 6

Analog input

A voltage becomes a number from 0 to 1023, and a program decides from it.

Learning objectives: students will be able to

  • Read a voltage with analogRead and convert it to millivolts
  • Use a threshold to make a decision from a reading
  • Explain hysteresis with an everyday example

Lesson plan

  1. Warm up (5 min): open Read a knob. Turn it and watch the numbers.
  2. Lesson (20 min): Reading a voltage.
  3. Lesson (20 min): Deciding from a reading, the night light.
  4. Close (5 min): what is one count worth, in millivolts?

Ask the class

  • On a 5 V Uno, about how many millivolts is one count of analogRead?
  • Why does a thermostat not switch on and off at exactly the same temperature?

Graded work

  • Reading a voltage: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Deciding from a reading: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Rebuild Read a knob: a potentiometer across 5 V and ground with its wiper on A0. Hand it in. Assign Read a knob as a template and add these checks. Our own build passes every one:
  • Check: The monitor prints the A0 reading (the serial monitor prints a line matching /A0 = \d+/ within 1500 ms).

Projects to open: Read a knob · Night light

Vocabulary

Analog
A value that can be anything in a range, not just on or off.
ADC
Analog-to-digital converter: turns a voltage into a number.
Threshold
The value where a decision changes.
Hysteresis
Two thresholds, one going up and one going down, to stop flickering.

Standards: 2-CS-02, 2-DA-08

Week 7

PWM, light and sound

Brightness from a digital pin, a breathing LED and a melody on a piezo.

Learning objectives: students will be able to

  • Define duty cycle and relate it to brightness
  • Use analogWrite on a PWM pin
  • Play notes with tone() and noTone() from a list

Lesson plan

  1. Warm up (5 min): run Fade an LED. How does a digital pin make in-between brightness?
  2. Lesson (20 min): Brightness from a digital pin.
  3. Build (20 min): open Piezo melody and rewrite the tune.
  4. Close (5 min): what does a 25 percent duty cycle average to on 5 V?

Ask the class

  • What average voltage does a 25 percent duty cycle give on a 5 V pin?
  • In Piezo melody, why is there a short gap after every note?

Graded work

  • Brightness from a digital pin: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Rebuild Fade an LED: an LED and 220 ohm resistor on pin 9, breathing with analogWrite. Hand it in. Assign Fade an LED as a template and add these checks. Our own build passes every one:
  • Check: Pin 9 switches at the Uno’s PWM rate (pin 9 on uno1 carries PWM at 490 Hz, within 20 Hz).

Projects to open: Fade an LED · Piezo melody · RGB color mixer

Vocabulary

PWM
Pulse width modulation: switching fast so the average sets the level.
Duty cycle
The percentage of time a pin is high.
Frequency
How many times a second something repeats, in hertz.
Piezo
A small speaker that clicks with each voltage change.

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

Week 8

Serial and functions

Printing to the monitor, taking commands, and writing a function once.

Learning objectives: students will be able to

  • Print values to the serial monitor and read characters back
  • Act on a typed command
  • Write a function with parameters and call it

Lesson plan

  1. Warm up (5 min): what would you want a board to tell you while it runs?
  2. Lesson (15 min): Making the board talk.
  3. Lesson (15 min): Taking commands.
  4. Lesson (15 min): Write it once, a function.

Ask the class

  • Why does printing a long line take real time at a given baud rate?
  • What makes a function with parameters easier to reuse than copied code?

Graded work

  • Making the board talk: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Taking commands: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Write it once: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: Reaction timer

Vocabulary

Serial monitor
A window that shows what the board prints, and sends what you type.
Baud rate
How many bits a second a serial line carries.
Function
A named block of code you can call.
Parameter
A value handed to a function when it is called.

Standards: 2-AP-14, 2-CS-02

Week 9

Final project

Plan a build as inputs, processing and outputs, build it, test it, and present it as a link.

Learning objectives: students will be able to

  • Plan a project as inputs, processing and outputs before wiring
  • Use one variable to track what state a program is in
  • Test a project against its own requirements and refine it

Lesson plan

  1. Plan (1 period): pick a brief (a reaction game, a metronome, a night light that fades, or their own) and list inputs, processing and outputs.
  2. Lesson (1 period): One variable that says where you are, the state machine.
  3. Build and test (2 to 3 periods): build it, write three tests it must pass, and fix what fails.
  4. Present (1 period): a two-minute demo from the shared link.

Ask the class

  • What states does your project have, and what moves it from one to the next?
  • Which of your tests failed first, and what did you change?

Graded work

Projects to open: Reaction timer · Metronome · Electronic dice

Vocabulary

State machine
A program that is always in one named state, with rules for moving between them.
Requirement
Something the finished project must do.
Test case
A specific input and the result it should give.
Iteration
Improving a design by testing and changing it again.

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

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, 4, 5, 7
2-CS-02CSTADesign projects that combine hardware and software components to collect and exchange data.1, 3, 6, 8
2-AP-10CSTAUse flowcharts and/or pseudocode to address complex problems as algorithms.2
2-AP-11CSTACreate clearly named variables that represent different data types and perform operations on their values.4
2-AP-17CSTASystematically test and refine programs using a range of test cases.5, 9
2-DA-08CSTACollect data using computational tools and transform the data to make it more useful and reliable.6
2-AP-16CSTAIncorporate existing code, media, and libraries into original programs, and give attribution.7
2-AP-14CSTACreate procedures with parameters to organize code and make it easier to reuse.8
3A-AP-13CSTACreate prototypes that use algorithms to solve computational problems by leveraging prior student knowledge and personal interests.9
3A-AP-17CSTADecompose problems into smaller components through systematic analysis, using constructs such as procedures, modules, and/or objects.9
2-AP-15CSTASeek and incorporate feedback from team members and users to refine a solution that meets user needs.9
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.