Test The Build-In Sensor

Touch Sensor

Prepare these things :

  1. ESP-32

Variation of Touch Sensor

I do think that the touch sensor before is very simple. So I made some modifications on the breadboard.

// set pin numbers
const int touchPin = 15; // the number of the touchPin
const int ledPin1 = 23; // the number of first LED pin
const int ledPin2 = 5; // the number of second LED pin
// change with your threshold value
const int threshold = 50;
// variable for storing the touch pin value
int touchValue;
void setup(){
Serial.begin(115200);
delay(1000); // give me time to bring up serial monitor
// initialize the LED pin as an output:
pinMode (ledPin1, OUTPUT);
pinMode (ledPin2, OUTPUT);
}
void loop(){
// read the state of the pushbutton value:
touchValue = touchRead(touchPin);
Serial.print(touchValue);
// check if the touchValue is below the threshold
// HIGH = LED ON
// LOW = LED OFF
if(touchValue < threshold){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
delay(50);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(50);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
delay(100);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
delay(50);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
delay(50);
Serial.println(" - LED on");
}
else{
digitalWrite(ledPin1, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);
delay(1000);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1, LOW);
delay(1000);
digitalWrite(ledPin1, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(1000);
digitalWrite(ledPin2, HIGH);
delay(1000);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
Serial.println(" - LED off");
}
}

Hall Effect Sensor

In this sensor, the tools needed are ESP-32, bread boards, and magnets.

Temperature Sensor

In this sensor, the only tools needed are an ESP-32 and a breadboard.

YAY, you reached the end of this tutorial. Hope you enjoy it, good luck :)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andreana Hartadi Suliman

Andreana Hartadi Suliman

If we are afraid of failure, it means we have limited our ability. — Hi, nice to see you here. Have a good day!