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

Arduino Uno R3

Detect a knock with the piezo

Use the kit piezo as a vibration sensor, observe its brief analog signal, and calibrate a knock threshold from evidence.

CSTA 2026 mapping candidatesNot reviewed by CSTA
MS-DAT-DI-27Data & Analysis

Students will

  • Explain how the piezo can act as either an input or output
  • Capture and compare brief analog peaks
  • Calibrate and test a knock event without assuming a universal threshold

Evidence of success

  • A table of baseline and tap readings
  • A threshold justified from observed peaks
  • Ten trials that distinguish intentional knocks from ordinary vibration

Hardware

  • Arduino Uno R3
  • Starter Kit piezo capsule
  • 1 MΩ resistor
  • Breadboard and jumper wires
  • Stable mounting surface

Prerequisites

  • Read an analog value
  • Open Serial Monitor
  • Choose a threshold from repeated measurements

Before class

  • Verify the actual piezo part and reviewed polarity guidance
  • Prepare the 1 MΩ resistor used across the sensor in the reviewed input circuit
  • Provide a repeatable mounting and tapping method

Reviewed connection map

Piezo vibration input

PiezoMechanical vibration creates a brief voltage
A0Analog peak measurement
Reviewed resistorPlaced across the piezo in the Starter Kit circuit
GNDSignal return
  1. Build the reviewed Starter Kit knock-sensor circuit with power disconnected.
  2. Connect the signal to A0 and secure the piezo before calibrating the threshold.

Build and test

  1. 01With power disconnected, connect the piezo to A0 and GND with the 1 MΩ resistor across the sensor
  2. 02Print the raw A0 reading and observe the resting baseline
  3. 03Apply ten gentle taps, recording peak values and missed or false events
  4. 04Choose a threshold above the resting noise and below most intentional taps
  5. 05Test the threshold with normal table movement and revise it for the installation

Read before uploading

Annotated Arduino sketch

const int PIEZO_PIN = A0;
const int LED_PIN = LED_BUILTIN;
int threshold = 100;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int reading = analogRead(PIEZO_PIN);
  bool knock = reading >= threshold;
  digitalWrite(LED_PIN, knock ? HIGH : LOW);
  if (knock) Serial.println(reading);
  delay(10);
}

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

Every small movement triggers an event

Secure the piezo, raise the threshold from recorded evidence, and separate taps with a short quiet interval.

Strong taps produce no reading

Verify A0, GND, the resistor placement across the piezo, part condition, and Serial Monitor timing.

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-DAT-DI-27

Summarize a data investigation process, including potential biases, limitations, and supporting evidence.

Students collect repeated sensor readings, identify limitations, and support a threshold or response with evidence.

Lesson evidence: Knock and background reading table
View the official 2026 CSTA standardsStandard text: Computer Science Teachers Association (2026), CC BY-NC-SA 4.0.

Supporting concepts

ohms-law · power-and-signals · sketch-foundations

Sources and review

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

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.