Embedded System Project — Blinking LED
Pada projek kali ini, Saya akan mencoba untuk menyalakan lampu LED Built-in pada board ESP-32 dan lampu LED eksternal dengan menggunakan Arduino IDE. Pada projek ini, saya mengerjakannya bersama teman saya Afkar Dhiya Ulhaq dan Ammardito Shafaat
Setup Environment
The steps required are:
1. Set Up Arduino IDE
- Download and install Arduino IDE (latest version), link : https://www.arduino.cc/en/software
- Install ESP-32 board in Arduino IDE
The steps required are:
- Click “File” in the top right corner and then select “Preferences”
- Copy the following link : https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json and paste it to the “Additional Board Manager URLs”
3. Download USB to UART bridge, link : https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers, it will help Arduino IDE to read the ESP-32 Board.
*You just have to extract the files
4. Set your Arduino IDE settings
The steps required are:
- Click “Tools” and then hover over the “Board” . After that click “Board Manager…”
- Install ESP-32 (If you already installed, you can skip this step)
- Click “Tools” and then hover over the “Board” . After that hover over the “ESP32 Arduino” and then select “DOIT ESP32 DEVKIT V1”
- Click “Tools” and then hover over the “Port”. After that choose your port (You can check your Port by searching it on Windows (Device Manager))
Part 1 — Blinking Internal LED
The steps required are:
1.Prepare ESP-32 board, micro USB cable type-B, and bread board.
2. Code your own “Blinking Program” (If you don’t want to make the program, You can use programs that are already available in the Arduino IDE, go to ‘File” and then hover over “Examples”. After that hover over “01.Basics” and the choose “Blink” program)
Explanation about the code:
First, we need to use a procedure to do the initialization , voids setup(), this procedure contains only one function
- pinMode(), to configure specific pins to behave as inputs or outputs.
In this case, LED_Built-in is an input
Second, we need to use a procedure to turn-on the Built-in LED which will blink repeatedly. void loop(), This procedure consists of 2 functions:
- digitalWrite() , used to give a HIGH or LOW value to the digital pin.
- delay(), used to delay the element that we will give action.
This program will turn on the LED for 1 second then turn off for 1 second repeatedly
*You can set the delay time as you wish, 1000 = 1 second
3. Connect Board to your Laptop/PC
4. Compile the program by clicking the “checklist” symbol
5. Upload your program by clicking the “right-arrow” symbol
Result :
Part 2 — Blinking External LED
The steps required are:
- Prepare ESP-32 board, micro USB cable type-B, bread board, LED, male to male cables, and resistor.
2. Make an electric circuit
- Connect the ground pin on ESP-32 to the negative rails of a bread board by using male-to-male jumper cable
- Connect the negative pin of the LED (the short leg) to the negative rails of a bread board. Put the 330 Ω resistor on the breadboard (place it anywhere you want)
- Connect the positive pin of the LED (the long leg) to the 330 Ω resistor
- Connect the the D5 pin (Digital-5) to the free-end of the resistor by using male-to-male jumper cable
NOTES :
“If the positive pin of the LED is on the terminal strips (as seen in the picture above), then connect the positive pin of the LED with the resistor horizontally”
“You can add more LED…..so that means you have to use more cable and resistor. And don’t worry about the program code, because it will be similar … just add some input according to the number of LEDs”
“if you want the LED lights to glow brightly you have to use a resistor with a small resistance”
3. Code your own “Blinking Program”
Explanation about the code:
First, we have to declare a variable for the input, in this case I named it “ledPin” and has a value integer 5. “5” means where you have to connect the cable on the ESP-32 (So i have to connect the cable to pin D5)
Second, we need to use a procedure to do the initialization , voids setup(), this procedure contains only one function
- pinMode(), to configure specific pins to behave as inputs or outputs
In this case, ledPin is an input
Third, we need to use a procedure to turn on the Built-in LED which will flash repeatedly. void loop(), This procedure consists of 2 functions:
- digitalWrite() , used to give a HIGH or LOW value to the digital pin.
- delay(), used to delay the element that we will give action.
4. Connect Board to your Laptop/PC
5. Compile the program by clicking the “checklist” symbol
6. Upload your program by clicking the “right-arrow” symbol
Result:
Trouble I’m Facing: (This section will be written in Bahasa Indonesia)
Pada saat melaksanakan tugas ini, tentunya saya mengalami berbagai masalah.
- Masalah terkait instalasi USB to UART bridge, saat saya mencoba untuk mengecek apakah sudah ada (terhubung) USB to UART bridge pada laptop saya, tampilan yang terjadi adalah sebagai berikut
Dalam menyelesaikan masalah ini, saya mencoba untuk trial & error. Saya mencoba untuk uninstall dan re-install USB-to-UART bridgenya, setelah itu restart PC, dan akhirnya masalah ini dapat terselesaikan. (not recommended)
- Masalah terkait komponen, pada saat saya mengerjakan project part-2 dengan teman saya, kami cukup lama terhambat karena keteledoran kami. Kami terbalik menempatkan posisi kaki LED (kami menempatkan kaki LED (-) pada bagian (-) pada bread board) , sehingga saat program dijalankan lampu tersebut tidak menyala. Jadi intinya kalian harus perhatikan detail-detail seperti itu.
- Masalah terakhir mungkin pengetahuan terkait rangkaian listrik yang sudah melunak, sehingga sering dalam pengerjaan projek ini sering kali saya melakukan trial & error.
For troubleshooting, if you are having trouble with ESP-32 or Arduino IDE, you can click the following links:
THE MORE YOU KNOW !!!!!!!!
ESP-32 has memory that stores programs that run on it, so that even if the micro USB has been removed from the PC and then you connect it again in PC, ESP32 can turn-on according to the last program compiled and uploaded. So if you want to turn-off the ESP-32 you have to create new file (file that consists of empty procedure), then compile and upload again.