ESP32 Reading Analog Inputs
MOHAMMAD SAIFIQUL AIMAN B MOHAMMAD ALI
192011145
Here’s a list of parts you need to assemble the circuit
ESP32 DOIT DEVKIT V1 Board
Potentiometer
Breadboard
Jumper wires
touchRead()
Reading the touch sensor is straightforward. In the Arduino IDE, you use the touchRead() function, that accepts as argument, the GPIO you want to read.
Assemble the circuit shown below
// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int potPin = 34;
// variable for storing the potentiometer value
int potValue = 0;
void setup() {
Serial.begin(115200);
delay(1000);
}
void loop() {
// Reading potentiometer value
potValue = analogRead(potPin);
Serial.println(potValue);
delay(500);
}
Uploading the Sketch :
Before clicking the upload button, go to Tools Board, and select the board you’re using. In my case. It’s the DOIT ESP32 DEVKIT V1 board. Also don’t forget to select your ESP32’s COM port.
Now, press the upload button.
Then, wait for the “Done uploading.” message:
Testing your project :
Comments
Post a Comment