Project Example :
In this example, we’ll read the state of a pushbutton, and light up an LED accordingly.
- SP32 DOIT DEVKIT V1 Board
- 5mm LED
- 330 Ohm resistor
- Pushbutton
- 10k Ohm resistor
- Breadboard
- Jumper wires
Testing project
After uploading the code, we need to test circuit. LED should light up when we press the pushbutton:
UNIT 2 -ESP32 TOUCH SENSOR
Touch Sensitive LED
Lets build a simple touch controlled LED circuit
- ESP32 DOIT DEVKIT V1 Board
- 5mm LED
- 330 Ohm resistor
- Breadboard
- Jumper wires
This code reads the touch value from the pin we’ve defined, and lights up an LED when the value is below the threshold, this means when you place your finger in the aluminum pad.
- Open Tools and open serial monitor at a baudrate 115200 and we will see new values being display every second.We can see that when we touch wire connected to GPIO 4 ,serial monitor show that LED is ON.
- Moreover,we can use serial plotter to better see the values.Tools > Serialplotter.
UNIT 3 -ESP32 PULSE-WIDTH MODULATION(PWM)
DIMMING AN LED
- ESP32 DOIT DEVKIT V1 Board
- 5mm LED
- 330 Ohm resistor
- Breadboard
- Jumper wires
GETTING THE SAME SIGNAL ON DIFFERENT GPIOs
We can get the same signal from the same channel in different GPIOs. To achieve that, we just need to attach those GPIOs to the same channel on the setup().
Let’s modify the previous example to dim 3 LEDs using the same PWM signal from the same channel.
- ESP32 DOIT DEVKIT V1 Board
- 3x 5mm LED
- 3x 330 Ohm resistor
- Breadboard
- Jumper wires
- All the GPIOs are outputting the same PWM signal.So all three LED increase and decrease the brightness simultaneously,resulting in a synchronized effect.
ESP32 READING ANALOG INPUTS
In this section we’ll learn how to read an analog input with the ESP32. This is useful to read values from variable resistors like potentiometers, or analog sensors.
To see how this works let’s make a simple example to read an analog value from a potentiometer.
- ESP32 DOIT DEVKIT V1
- Board
- Potentiometer
- Breadboard
- Jumper wires
Upload the code to ESP32. Before uploading any code to ESP, always check the right board and COM port selected.
0 Comments