Guided physical computing, beginning with the Arduino Starter Kit Classroom Pack

Arduino Uno R3

Build event and state logic

Distinguish an input transition from a held condition and move a system through explicit named states.

CSTA 2026 mapping candidatesNot reviewed by CSTA
MS-PRO-RD-17ProgrammingMS-PRO-TR-19Programming

Students will

  • Detect a new press rather than repeatedly acting while a button is held
  • Represent system behavior with explicit states
  • Define a reset or recovery transition

Evidence of success

  • Holding the button does not advance through every state
  • Each state has a named observable output
  • The system can return to its defined starting state

Hardware

  • Arduino Uno R3
  • Momentary pushbutton
  • Built-in LED or protected external LED
  • Breadboard and jumper wires

Prerequisites

  • Read a reliable digital input
  • Control an LED
  • Use conditions and variables

Before class

  • Prepare a simple two- or three-state diagram
  • Keep the first state machine small
  • Distinguish contact bounce from held-state repetition

Reviewed connection map

Button event and visible state

Button D8-GNDActive-low physical input
New-press detectorCompares current and previous readings
READY / ACTIVE / COMPLETENamed program states
LED_BUILTINVisible evidence of ACTIVE
  1. Connect the button between D8 and GND.
  2. The output uses the built-in LED; an external protected LED may be substituted only with a matching reviewed pin and circuit.

Build and test

  1. 01Observe how a held button repeats a level-based action
  2. 02Store the previous input and detect the HIGH-to-LOW transition
  3. 03Define READY, ACTIVE, and COMPLETE states
  4. 04Allow one event to advance each state
  5. 05Add a deliberate reset path and test unexpected presses

Read before uploading

Annotated Arduino sketch

const int BUTTON_PIN = 8;
enum SystemState { READY, ACTIVE, COMPLETE };
SystemState state = READY;
bool previousPressed = false;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  bool pressed = digitalRead(BUTTON_PIN) == LOW;
  bool newPress = pressed && !previousPressed;
  if (newPress) {
    if (state == READY) state = ACTIVE;
    else if (state == ACTIVE) state = COMPLETE;
    else state = READY;
  }
  digitalWrite(LED_BUILTIN, state == ACTIVE);
  previousPressed = pressed;
  delay(20);
}

Optional engineering record

Record evidence from this lesson

Choose the prompts that help students explain predictions, evidence, debugging, and transfer. Saving creates a new entry in this browser’s Rudi notebook.

Record your thinking — optional4 prompts

Use these prompts if they help students capture evidence, decisions, or questions. You do not need to complete every prompt or create an entry at every step.

Nothing is saved until you choose this button.

Troubleshooting

One press advances several states

Act only on the transition and add a short debounce interval if the physical contact produces repeated edges.

The system becomes stuck

Trace every state's allowed transitions and make sure at least one defined path returns to READY.

2026 middle school standards

Potential CSTA connections

Not reviewed by CSTA

These are evidence-based crosswalk candidates for curriculum review—not a claim of official alignment.

MS-PRO-RD-17

Analyze the roles of iteration, selection, variables, and procedures in a segment of code.

Students trace variables, selection, or iteration in the supplied sketch and connect code to physical behavior.

Lesson evidence: State transition trace
MS-PRO-TR-19

Use systematic strategies to test, refine, and document changes to a computing technology to meet the intended purpose.

Students isolate variables, compare observed behavior with the intended purpose, and document a revision.

Lesson evidence: Event-sequence test table
View the official 2026 CSTA standardsStandard text: Computer Science Teachers Association (2026), CC BY-NC-SA 4.0.

Supporting concepts

floating-inputs · sketch-foundations

Sources and review

Arduino Uno R3 documentationArduino Projects Book · CC BY-NC-SA 3.0

Starting point, not verified curriculum. Review the actual hardware, circuit, code, power requirements, and classroom conditions.

After teaching this lesson

Make one bounded change—or connect the skill to a project.