Simulator

A traffic light simulator with a crossing button

Mokxi is a free online traffic light simulator that runs in your browser, with nothing to install and no account needed. An Arduino Uno runs a traffic light module through green, yellow and red, a pushbutton asks for the walk signal sooner, and a piezo beeps while it is safe to cross. Press the button during the green and the light changes 1.5 seconds later.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: a crosswalklive0.000 s 0.00x
Hold the button
Press the button while the light is green, or click anything else to open the circuit in the editor.

What you can do here

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

  • Press the crossing button and watch the green cut short
  • Change the green, yellow and walk times in the sketch
  • Build the same light from three LEDs and three resistors
  • Add a second light for the cross street and keep the two in step
  • Rewrite the loop as a state machine on millis() instead of delay()
  • Watch the three pins on the logic analyzer as the cycle runs

What the running circuit shows

One cycle, about fifteen seconds.

The sketch holds green for 8 seconds and yellow for 2, then red while walkers cross: sixteen 2000 Hz beeps a quarter second apart, then twelve quicker ones at 2500 Hz to hurry. In the engine one cycle takes about 15.2 seconds, and the serial monitor prints “cars: green”, “cars: yellow”, “cars: red, walk” and “hurry” as it goes.

During the green the sketch reads the button every 10 ms. Press it a second into the green and it prints “button: walk soon” and ends the green 1.5 seconds later, so in the engine the light turns yellow about 2.5 seconds after it went green instead of 8. The module’s resistors are on its own board, so its three pins go straight to Uno pins 13, 12 and 11; with the green lit, pin 11 sits at about 4.74 V.

How the light is modeled

Three real LEDs on one small board.

Each lamp is the same diode model as a plain LED, in its own color, behind its own 220 ohm resistor on the module, and the three cathodes share one GND pin: leave GND unwired and nothing lights. The Uno runs the sketch’s compiled code, so delay(), millis() and tone() keep the times they would on a board. The piezo’s tone is not played through your speakers; the piezo shows the frequency it is playing instead.

What it leaves out: the real resistor on your module, which these boards are sold without a schematic for, so 220 ohm is an assumption, and how bright each color looks beside the others. The button never bounces unless you set it to, and the sketch would cope if it did, since it acts only on the first press of each green.

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.

Can I build the traffic light from Tinkercad here?

Yes. Three LEDs with a 220 ohm resistor each on three pins is the same circuit as this module, and the Arduino traffic light page builds it step by step. A traffic light sketch that uses only pinMode, digitalWrite and delay runs here as it is.

How do I make a traffic light without delay()?

Note the time each light started with millis(), and in loop() check whether its time is up, so the board can read the button between checks. The state machine page shows the pattern on a four-state game.

Does it work on a Chromebook?

Yes. It runs in Chrome with nothing to install, which is how many school coding and engineering classes use it.

More simulators

Each one opens on a circuit that is already running.

Cross the road

Open the circuit, press Run and push the button. Nothing to install, and no account needed.