Arduino Uno: potentiometer dims LED (analogRead → analogWrite)
Potentiometer on A0 dims the LED on D9, editable sketch.
- Arduino Uno
Open in the simulatorNo account needed: press Simulate and it runs.
How it works
Arduino Uno (ATmega328P, 16 MHz) with real firmware from an Arduino sketch. Potentiometer RV1 on A0 sets the brightness of the LED on D9 (PWM from Timer1); the sketch writes the reading over Serial (console in the inspector). Change the sketch in the Code view and click "Compile": the server builds it with arduino-cli. Turn the potentiometer during the simulation.
Parts
Firmware
sketch.ino · 10 lines
// analogRead(A0) -> analogWrite(9) (Timer1 PWM) and Serial report every 100 ms
void setup() { Serial.begin(115200); pinMode(9, OUTPUT); }
void loop() {
int v = analogRead(A0);
analogWrite(9, v / 4);
analogWrite(5, 64); // Timer0 fast PWM, 25 %
analogWrite(3, 191); // Timer2 phase-correct PWM, 75 %
Serial.print(F("A0=")); Serial.println(v);
delay(100);
}Open in the simulator