Simulator

A potentiometer simulator with a knob you can turn

Mokxi is a free online potentiometer simulator that runs in your browser, with nothing to install and no account needed. A 10k potentiometer across 5 V on a breadboard, its wiper on an Arduino Uno’s A0, and an LED on pin 9 that gets brighter as you turn the knob. The serial monitor says how far around the knob is and what the LED is given.

  • 269parts on the bench
  • 32boards running now
  • 1.00xreal time, on every board
Arduino Uno: a knob dims an LEDlive0.000 s 0.00x
Click to open it in the editor
Turn the knob to change the brightness, 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.

  • Turn the knob and watch the LED follow it
  • Read the wiper’s voltage on A0, anywhere from 0 to 5 V
  • Switch the taper from linear to log in the properties panel
  • Change the track from 10k to 1k or 100k and see what does and does not change
  • Wire the pot as a variable resistor in series with an LED, with no board at all
  • Edit the Arduino code and press Run again

What the running circuit shows

A voltage divider you set with your thumb.

The potentiometer’s two outer legs go to 5 V and ground, so its track is a voltage divider and the wiper picks off a share of the supply that follows the knob. The sketch reads it with analogRead, 0 to 1023, smooths it, shifts it right by two to get 0 to 255, and writes that to pin 9 with analogWrite.

In the engine the knob starts centered: the wiper sits at 2.50 V and the serial monitor says “knob 50% -> pwm 128”. Turn it a quarter of the way around and the wiper reads 1.25 V; turn it all the way and it reads 5.00 V and the LED is at its brightest. The “Read a knob” project reads the same knob with no LED, and prints “A0 = 512 (2502 mV)” with it centered.

How the potentiometer is modeled

A resistive track with a wiper, solved with the rest of the circuit.

The potentiometer is two resistors that add up to its value, split where the wiper is, and the engine solves them with everything else on the bench. So a load on the wiper pulls it down the way it would on a real board, and the track’s value only matters when something draws current from it: with nothing but an analog input on the wiper, a 1k, a 10k and a 100k pot all read 2.50 V when centered.

The taper is a property. Set it to log, the audio taper a volume knob has, and the centered knob gives 1.25 V instead of 2.50 V, so the serial monitor says “knob 25% -> pwm 64”. What it leaves out: a real pot’s wiper is a sliding contact that crackles and wears. The sketch smooths the reading anyway, which is the habit a real one needs.

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.

How do I wire a potentiometer to an Arduino?

One outer leg to 5 V, the other to GND, and the middle leg, the wiper, to an analog pin such as A0. analogRead then gives 0 at one end of the travel and 1023 at the other.

Can I use a potentiometer as a variable resistor?

Yes. Use the wiper and one outer leg only and it is a rheostat, a resistance from zero up to the pot’s value. In series with an LED and its resistor it makes a dimmer with no microcontroller at all.

Is the knob’s travel linear?

By default, yes: half way around is half the voltage. Switch the taper to log in the properties panel for an audio taper, where half way around gives a quarter of the voltage.

Turn a knob

Open the circuit, turn the knob and press Run. Nothing to install, and no account needed.