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

Arduino Uno R3

Tilt to event

Turn a tilt-switch change into a stable, observable event rather than treating orientation as a guaranteed continuous measurement.

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

Students will

  • Read a tilt switch with a defined resting state
  • Distinguish a held state from a change of state
  • Test orientation and vibration limits

Evidence of success

  • Stable orientations produce repeatable readings
  • The sketch reports transitions separately from held states
  • The student identifies vibration as a possible source of extra transitions

Hardware

  • Arduino Uno R3
  • Tilt switch from the Starter Kit
  • Breadboard and jumper wires

Prerequisites

  • Read a reliable digital input
  • Open Serial Monitor

Before class

  • Verify the actual switch closes in at least one orientation
  • Prepare a stable mounting method
  • Explain that the switch reports contact, not an angle

Reviewed connection map

Tilt switch input

D8 INPUT_PULLUPStable digital input
Tilt switchContact opens or closes with orientation
GNDClosed contact reads LOW
  1. Connect the verified tilt switch between D8 and GND.
  2. Secure it so deliberate orientation changes can be distinguished from vibration.

Build and test

  1. 01Connect the tilt switch between D8 and GND
  2. 02Configure D8 with INPUT_PULLUP
  3. 03Observe the state in several stable orientations
  4. 04Detect and print only changes from the previous state
  5. 05Repeat ten controlled tilts and record false or repeated events

Read before uploading

Annotated Arduino sketch

const int TILT_PIN = 8;
bool previousState;

void setup() {
  pinMode(TILT_PIN, INPUT_PULLUP);
  Serial.begin(9600);
  previousState = digitalRead(TILT_PIN);
}

void loop() {
  bool currentState = digitalRead(TILT_PIN);
  if (currentState != previousState) {
    Serial.println(currentState == LOW ? "contact closed" : "contact open");
    previousState = currentState;
    delay(30);
  }
}

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

Many events occur during one movement

Mount the sensor securely and add a short settling interval after a detected change.

No orientation changes the reading

Verify the switch legs, breadboard rows, INPUT_PULLUP setting, and D8-to-GND path.

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-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: Orientation and repeated-event test
View the official 2026 CSTA standardsStandard text: Computer Science Teachers Association (2026), CC BY-NC-SA 4.0.

Supporting concepts

floating-inputs · component-boards

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.