Search code examples
pythonesp32micropython

MicroPython makes the ESP32 freeze


I wanted to try out MicroPython on my ESP32. The flashing seems to be working, but even on the first script it fails. I tried to use this code:

from machine import Pin
import time
i = 0
led = Pin(1, Pin.OUT)
while i < 10:
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)
    i += 1

print("Done!")

and than type ìmport blink in repl. The LED is blinking 11 times (at least that's my counting). After this part is finished, the LED stays on the hole time and you can't do anything. Done isn't printed at all, so there is probably some problem with the loop. I also tried to enter it in the repl Python-Shell using:

  1. import machine
  2. led = machine.Pin(1, machine.Pin.OUT) and at this point it freezes.

Do you know any possible fix for this problem?


Solution

  • Did you tried by changing the pin to 4 or 5 because pin 1 is a TX pin