Project 2: Simple I/O
In this article, you will learn how to make simple input and output using your ESP32 and Arduino IDE. For the input you will be using push switch button and for the output using LED.
Required Hardware and Software
- ESP32 Devkit V1
- Jumper wires (male to male)
- 330 Ohm Resistor
- 10k Ohm Resistor
- Breadboard
- Push button 4 pin
- 5mm LED
Steps
- First of all, you need to place your ESP32 to the breadboard. Give one space for the right side of ESP32 like the picture below because we will be using that.
2. After that, put the push button in the middle of the breadboard (between e and f column). Put the LED not to far from the push button. Remember the different in the LED because it will be crucial. My LED have different in the feet length.
3. Now we will arrange the cable for this project. First cable is from the hole in the right side of 3V3 pin in the ESP32. That cable will be connect to the right side of the red line. The red and blue line represent the electric potential between positive (red) and negative (blue). Second cable is from the hole in the right side of GND pin in the ESP32 and will be connect to the left side of the blue line. It will look like this picture.
4. Next, we will arrange another cable. It will be from the right side of D4 pin and connect to the right side of the push button. The bottom part next to the black circle in the push button. Another one will be from D5 pin and connect to left side of the longer feetof the LED. For the last cable, it will be from the right side of upper part push button, next to the black circle. It will connect to the right side of the red line. It will look like this.
5. After that, we will put our resistor in the breadboard. First, we will put the 10k Ohm resistor from the right side push button and connect it to the left side of the blue line. Second, put the 330 Ohm resistor from the right side of LED to the left side of the blue line. It may be confuse you a little bit so just take a look at the picture below.
6. After we finish the installation for the hardware, now let’s begin to program it. First, connect your ESP32 to your computer/laptop using the micro USB cable. Open Arduino then File > New. Now you have a new sketch.
7. Copy and paste this code your Arduino
8. Then, verify and upload your code. Remember when uploading hold the BOOT button in your ESP32 until it done uploading. Now, you have a simple input and output with your ESP32. Here is a video of my own project.
Thank you for reading this article. See you in the next project!