To familiarize you with the process of creating and executing code on your ESP32/ESP8266 boards, we'll upload a new script that simply blinks your ESP32 or ESP8266's on-board LED.
from machine import Pin from time import sleep led = Pin(2, Pin.OUT) while True: led.value(not led.value()) sleep(0.5)
Running the Script
The on-board LED will start blinking.
To stop the program, press the STOP button or CTRL+C.
Run the Code Automatically
Uploading Code to the ESP32 Board
2) Next, select MicroPython device.
3) Name the file main.py; otherwise, it will not start automatically on the ESP32 or ESP8266.
Notice that the pop-up window displays the files that are currently saved on the board's memory. There should be a file named boot.py. That file is generated by default when you burn MicroPython firmware.
5) Now, hit the on-board RST/EN button to restart the board and start the code.
After saving the file, you can remove and reapply power to the board, or power it using a power supply other than your computer.
When you power up the board, the LED will begin to blink automatically. This implies the main.py file was successfully uploaded to the board and is now running automatically.






0 Comments