-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteste_de_FSR.ino
33 lines (27 loc) · 1013 Bytes
/
teste_de_FSR.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-force-sensor
*/
#define FORCE_SENSOR_PIN 0 // ESP32 pin GIOP36 (ADC0): the FSR and 10K pulldown are connected to A0
void setup() {
Serial.begin(9600);
}
void loop() {
int analogReading = analogRead(FORCE_SENSOR_PIN);
Serial.print("The force sensor value = ");
Serial.print(analogReading); // print the raw analog reading
if (analogReading < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (analogReading < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (analogReading < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (analogReading < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
delay(1000);
}