Source: https://mokxi.com/buzzer-simulator

Simulator

# A buzzer simulator that shows every tone your code plays

Mokxi is a free online buzzer simulator for Arduino that runs in your browser, with nothing to install and no account needed. An Arduino Uno plays the opening of “Ode to Joy” on a passive piezo buzzer with tone(), one note at a time, and lights an LED on each beat. The buzzer shows the frequency it is being driven at, and the serial monitor names each note.

Start building free or see the buzzer part

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The tune plays, then rests for two seconds. Click the circuit to open it in the editor and write your own.

## What you can do here

In the circuit above, or in the editor it opens.

- Play notes with tone() and stop them with noTone()
- Read the frequency each note really comes out at
- Change the tune, the tempo or the gap between notes
- Swap in an active buzzer that beeps from a plain digitalWrite
- Make a parking sensor that beeps faster as something gets closer
- Save the tune and share it with one link

## What the running circuit shows

A square wave at the pitch you ask for.

tone(pin, frequency) starts timer 2 toggling pin 8 at that frequency and returns at once, so the sketch decides how long each note lasts with its own delay() and stops it with noTone(). The 30 ms gap after each note is what makes two notes of the same pitch into two notes rather than one long one.

In the engine the piezo reads each note’s frequency as it plays: the E the sketch asks for at 330 Hz comes out at 330.7 Hz, and the C at 262 Hz at 262.6 Hz, because the timer can only divide the 16 MHz clock by whole numbers. The fifteen notes take about 6.4 seconds, then the serial monitor says “again in two seconds”.

## Active and passive buzzers

One beeps by itself, the other needs a tone.

The piezo here is a passive buzzer: it makes whatever frequency the pin drives it at, which is why it can play a tune. An active buzzer has its own oscillator inside, so a plain HIGH makes it beep at its one pitch and tone() is not needed. Both are in the parts bin, and the active buzzer project beeps one from digitalWrite.

What it leaves out: the sound. Mokxi does not play the tone through your speakers; the buzzer shows the frequency on its face, which is quieter in a classroom and exact. A real piezo is also loud at its resonant frequency and quiet away from it, which this one does not model.

Play a melody with tone() A buzzer with Arduino The ultrasonic sensor simulator The PWM simulator

## Questions

Is it free?

Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.

Do I need an account?

No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.

What is the difference between an active and a passive buzzer?

An active buzzer has an oscillator inside and beeps at one pitch when it gets power. A passive buzzer, or piezo, makes whatever frequency it is driven at, so it can play notes with tone().

Can I play a song?

Yes. The sketch keeps the tune as two lists, the notes in hertz and the lengths in beats; replace them with your own and press Run.

Can I make it play faster?

TEMPO_MS is the length of half a beat, 200 ms in this sketch. Make it smaller and the tune plays faster; set GAP_MS to 0 and repeated notes run together.

## More simulators

Each one opens on a circuit that is already running.

Online circuit simulator Breadboard simulator ESP32 simulator Op-amp simulator Logic gate simulator LED circuit simulator Servo simulator LCD simulator OLED simulator NeoPixel simulator 7 segment display simulator LED matrix simulator Stepper motor simulator Motor driver simulator Ultrasonic sensor simulator Rectifier simulator Digital circuit simulator Potentiometer simulator PWM simulator Relay simulator Shift register simulator DHT11 simulator RFID simulator Accelerometer simulator RGB LED simulator MOSFET simulator Circuit simulator for kids Flip-flop simulator Multiplexer simulator Full adder simulator I2C simulator UART simulator Thermistor simulator PIR sensor simulator Oscilloscope simulator Multimeter simulator DC motor simulator Traffic light simulator Diode simulator Capacitor simulator Series and parallel circuit simulator Wheatstone bridge simulator Voltage regulator simulator Soil moisture sensor simulator Zener diode simulator Solar panel simulator AC circuit simulator Thevenin simulator Decoder simulator Encoder simulator PID simulator Robot arm simulator Load cell simulator IR sensor simulator LM35 simulator HC-05 Bluetooth simulator nRF24L01 simulator

## Play a tune

Open the circuit, change a note and press Run. Nothing to install, and no account needed.

Start building free Open the editor
