running light always stops briefly

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Posts: 1
Joined: Wed Oct 21, 2020 7:35 pm

running light always stops briefly

Post by kolja » Wed Oct 21, 2020 7:56 pm

I'm just trying my first steps with micropython on an ESP8266. I have a little experience with the Arduino language.
As a first task I would like to program a running light made of 7 LEDs. The structure is on a breadboard
and works because I can individually turn each LED on, off and using PWM.

As soon as I want to switch the LED on and off one after the other via a loop, the running light always stops briefly.

I recorded a video to show it:

The code is very simple:

Code: Select all

import time, math
from machine import Pin, PWM
import esp

leds = list( PWM(Pin(i), freq=80, duty=0) for i in [0, 15, 13, 12, 14, 4, 5])

for j in range(100):
    for led in leds:
What amazes me above all is that the debug output via print () continues while the running light stops.
I tried different PWM frequencies and found that the effect is less when the frequency is significantly lower (100Hz).

I'm using a NodeMCU with the current Python version 1.13.
I have Thonny and µPyCraft as software under Windows 10.

My questions are: am I making a mistake?
Am I still thinking too much in Arduino?
How is the right way in micropython?

Kind regards


User avatar
Posts: 2015
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: running light always stops briefly

Post by jimmo » Wed Oct 21, 2020 10:57 pm

There were some issues with PWM on ESP8266 that would explain this -- see and but this was apparently fixed before v1.13 was released.

I assume this works completely fine if you just use the pins directly (without PWM) and set them on/off?

Post Reply