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.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: piezo melodylive0.000 s 0.00x
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
  • Hear the tune through your speakers in the editor
  • 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 real sound. You hear the note through your computer’s speakers, as a soft tone at the frequency the buzzer sees, and its face shows that frequency exactly; the speaker button on the canvas toolbar mutes it for a quiet classroom. A real piezo is also loud at its resonant frequency and quiet away from it, which this one does not model.

How it works

Three steps from a blank tab to a running circuit.

  1. Open the editor

    It runs in your browser tab. Nothing to install, and you need no account to start.

    Your first project
  2. Wire it and write the code

    Drag parts onto a breadboard, run each wire from pin to pin, and write the sketch beside it.

    Wiring
  3. Press Run

    Your sketch compiles in the tab and runs on a model of the chip, with the Serial Monitor beside it.

    Run and serial
Reviews

What makers say about Mokxi.

“The AI checker helps check and correct my circuits, and it has way more components than Tinkercad. As a student I really appreciate the tool.”

ChloeEngineering student

“I’d been looking for a real online electronic simulator that was intuitive and complete when I found Mokxi. I was able to quickly import a Fritzing file and my Arduino sketch and start testing. Mokxi has all of the makings for the best online Arduino simulator I have been able to find!”

JayModel builderFeatured in his DioramaOS post

“I’m using Mokxi to develop and simulate an STM32-based four-wheel-drive robot car before building the actual hardware. It allows me to experiment with DC motor control, PWM, RPM measurement using photointerrupters, and different acceleration, braking, and reversing strategies, helping me understand and refine the system before implementing it in real life.”

NusretRobot car builder, Hamburg

Share your story

FAQ

Questions, answered.

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.

Play a tune

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