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
Arduino Uno R3
Distinguish an input transition from a held condition and move a system through explicit named states.
Reviewed connection map
Read before uploading
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
Choose the prompts that help students explain predictions, evidence, debugging, and transfer. Saving creates a new entry in this browser’s Rudi notebook.
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.
Act only on the transition and add a short debounce interval if the physical contact produces repeated edges.
Trace every state's allowed transitions and make sure at least one defined path returns to READY.
2026 middle school standards
These are evidence-based crosswalk candidates for curriculum review—not a claim of official alignment.
Students trace variables, selection, or iteration in the supplied sketch and connect code to physical behavior.
Lesson evidence: State transition traceStudents isolate variables, compare observed behavior with the intended purpose, and document a revision.
Lesson evidence: Event-sequence test tablefloating-inputs · sketch-foundations
Starting point, not verified curriculum. Review the actual hardware, circuit, code, power requirements, and classroom conditions.
After teaching this lesson