All tutorials

3 · Outputs & actuators

Potentiometer → brightness

Intermediate15 min

Goal

Set LED brightness with the knob (10 bits to 8 bits).

Why it matters

map() is the universal tool for linking two different scales.

Steps

  1. 01Read A0 (0–1023).
  2. 02Convert with map(value, 0, 1023, 0, 255).
  3. 03Send the result to analogWrite() on pin 9.

This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.

Next tutorials