All tutorials

3 · Outputs & actuators

Buzzer: playing notes

Intermediate15 min

Goal

Play a scale with tone() on pin 8.

Why it matters

Frequency sets the pitch: your first look at periodic signals.

Steps

  1. 01Add a buzzer on pin 8.
  2. 02Declare an array of frequencies (262, 294, 330, 349, 392…).
  3. 03Play them with tone(8, f, 300) inside a for loop.
  4. 04Finish with noTone(8).

This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.

Next tutorials