I am trying to control Leds with a button to change if one is on or off and a potentiometer to control the brightness of the Leds. I am using a Raspberry Pi Pico. Is there a way to do this.

  • This might help: microcontrollerslab.com/…
    – tlfong01
    Nov 2, 2022 at 5:55
  • 1
    You COULD use a potentiometer but if this is what you want just omit the Pico. It would make more sense to use a program.
    – Milliways
    Nov 2, 2022 at 6:20

1 Answer 1



The Pico has general GPIO you can use to read a button press or release.

The Pico has an ADC so you can read the potentiometer voltage.

The Pico has PWM which you can use to vary the brightness of the LEDs.

  • 1
    I am having trouble doing both of these at the same time. My button is able to turn on the LES, and separately, the potentiometer can adjust the brightness. However, it cannot do both. When setting up an LED for a button, it has to be led = machine.Pin(15, machine.Pin.OUT) However, when using a potentiometer for the same LED, it has to be: led = machine.PWM(machine.Pin(15)) I cannot have the same LED function with a button and a potentiometer. Nov 3, 2022 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.