# PWM of a solitary LED

**URL:** <https://forum.makecode.com/t/pwm-of-a-solitary-led/15622>\
**Category:** Arcade\
**Created:** [September 26, 2022, 11:50pm UTC](https://forum.makecode.com/t/pwm-of-a-solitary-led/15622 "2022-09-26T23:50:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xjordanx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/xjordanx/32/6537_2.png) [@xjordanx](https://forum.makecode.com/u/xjordanx)\
**Post date:** [September 26, 2022, 11:50pm UTC](https://forum.makecode.com/t/pwm-of-a-solitary-led/15622/1 "2022-09-26T23:50:35Z")

</div>

On my board I have an LED, which I can easily turn on and off via the TS code or block for it. But I need to be able to dim the LED using PWM. On the RP2040, all GPIOs are capable of PWM.

Yet when I try AnalogWrite for the LED pin the editor barfs.

Is there something I need to modify in order to support PWM on the LED pin?

It is NOT an APA102 or WS2812 etc. It’s just a plain ol’ LED on a common drain MOSFET controlled by a GPIO pin.

---

<div class="post-metadata">

**Author:** ![xjordanx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/xjordanx/32/6537_2.png) [@xjordanx](https://forum.makecode.com/u/xjordanx)\
**Post date:** [September 27, 2022, 4:16pm UTC](https://forum.makecode.com/t/pwm-of-a-solitary-led/15622/2 "2022-09-27T16:16:43Z")

</div>

I’ve seen people on YT doing this with regular “Dxx” outputs pins. I’ve configured the P\_10 (GPIO10) of the RP2040 on my board to be PIN\_LED, as well as P10, and D10.

When using “LED” in Arcade, I can turn it on and off, and CODAL will flash the LED if I precipitate any configuration errors.

When I removed the PIN\_LED from my config and just left it as PIN\_D10, and use the AnalogWrite and AnalogWritePeriod functions, it never lights at all… no matter what the period or PWM level I plug in.

Is there some other configuration compatibility issue?

This also raises another question which the configuration documents do not document: What is allowed when it comes to applying multiple possible configurations to a single device pin?

These might also be questions for @mmoskal

I appreciate the help. Just need more info about the bounds within which I need to work.
