Skip to content
Emblem of the National Guard of the Republic of UzbekistanGUARDTECH
All exercises

3. Brightness control (PWM)

Use the potentiometer to change the brightness of the LED on D9.

Task

  1. 1.Run the program and move the potentiometer slider.
  2. 2.analogRead() returns 0–1023 and analogWrite() takes 0–255; map() connects them.
  3. 3.Invert the brightness: the LED is off with the slider at its end.

Code

Tab inserts two spaces. To leave the editor press Esc, then Tab.

Virtual stand

Program not started

Pin states
PinPartState
A0Potentiometer512 · 2.50 V
D9Red LEDoff

Serial monitor 9600

The program has not sent anything over Serial yet.