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
kolja
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

Hello
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: https://streamable.com/0wwsn2

The code is very simple:

Code: Select all

import time, math
from machine import Pin, PWM
import esp
esp.osdebug(1)

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

for j in range(100):
    leds.reverse()
    for led in leds:
        led.duty(1023)
        print(led)
        time.sleep_ms(100)
        led.duty(0)
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

Kolja

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

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 https://github.com/micropython/micropython/issues/5965 and https://github.com/micropython/micropython/pull/5966 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