Simulator

A PIR sensor simulator: the HC-SR501 on an Arduino

Mokxi is a free online PIR motion sensor simulator that runs in your browser, with nothing to install and no account needed. An HC-SR501 motion sensor on an Arduino Uno’s pin 7, with an LED on pin 13 that copies its output. Click the sensor’s white dome to start something moving in front of it, and click again to stop.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: a PIR motion lightlive0.000 s 0.00x
Click to open it in the editor
Click the dome to wave at the sensor, or click anything else to open it in the editor.

What you can do here

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

  • Start and stop movement with a click and watch the output
  • Set the hold time, the trimmer on the real board, in the properties panel
  • Switch the jumper between repeat and single trigger
  • See the block time that makes a fresh PIR look broken
  • Switch a lamp, a relay or a buzzer from the output
  • Edit the Arduino code and press Run again

What the running circuit shows

High while it moves, and a while after.

The HC-SR501 does the sensing on its own board and gives a plain digital output: high while it sees movement, low when it does not. Its OUT pin is 3.3 V whatever it is powered from, which an Uno reads as HIGH. The sketch copies it onto the LED and prints each change.

In the engine a click on the dome puts OUT at 3.3 V, the LED lights and the serial monitor prints “motion detected”. Click again and the output stays high for the 2 second hold time, then drops and the monitor prints “all still”. Click right away and nothing happens for 2.5 seconds: that is the block time, when the module ignores everything after a pulse.

How the sensor is modeled

Hold, block and retrigger, as on the board.

Hold, block and retrigger are properties. Set the hold to 5 and the output stays high 5 seconds after the movement stops. With the jumper in repeat, the default, movement that goes on keeps the output high for as long as it lasts; set it to single and one movement gives one 2 second pulse, however long it goes on.

What it leaves out: the lens and its zones, range and angle. A click stands for something warm moving in view, so the sensor cannot be fooled by a heater or miss someone walking straight at it, as a real one can. A real module also needs up to a minute to settle after power-up; this one is ready at once.

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.

Why does my PIR sensor stay on?

Its hold time keeps the output high for a while after the movement stops, 2 seconds here and adjustable by a trimmer on the real board. With the jumper in repeat, ongoing movement keeps it on.

Why does my PIR sensor not react right after it turns off?

After each pulse it ignores everything for its block time, 2.5 seconds on the HC-SR501. Wait it out and it detects again.

Do I need a resistor on the PIR output?

Not to read it. OUT drives a clean 3.3 V signal straight into a digital pin. To switch a lamp or a relay, put a transistor between them.

More simulators

Each one opens on a circuit that is already running.

Wave at a sensor

Open the circuit, click the dome and press Run. Nothing to install, and no account needed.