Demo 1: Blinky - a Hello World on Arduino ESP32

1. Introduction
Let 's start with LED blinky example, it is equivalent to “Hello World”. We use Arduino ESP32 to blink the LED on/off every 1 second. You can also extend it with a Relay module (as a ON/OFF switch) that can control ON/OFF a high power electric devices such as electric motor, bulb, ... by using a small electric signal from micro controller.


Figure: Relay module with IN1, IN2 is small input signal from MCU and the opposite side for high power devices

2. Hardware
For Blinky demo, just connect:
[ESP3 IO14 and ESP3 GND to LED]

Figure: ESP32 connect to LED


For extension demo, connect:
[ESP32 IO18 - Relay IN1] 
[ESP32 GND - Relay GND]
Figure: ESP32 connect to Relay module

3. Software
If you are familiar with Arduino you see that it is very easy. First we use pinMode() function to set the pin IO14 as OUTPUT. Then we set the HIGH level for pin IO14 by using digitalWrite() function. We need a little delay so that we can monitor the LED is ON or OFF.

Start Arduino IDE > File > New > Save As > esp32led
Select your board in > Tools > Board > ESP32 Dev Module
Select Upload Speed in > Tools > Upload Speed > 115200
Select Flash Frequency in > Tools > Flash Frequency > 80MHz
Select the COM port that the board is attached to in > Tools > Port
Then Compile and Flash SW to ESP32
Figure: Press red button to compile and flash SW to ESSP32


Post a Comment

0 Comments