Flex Sensor
The flex sensor changes its resistance when flexed so we can measure that change using one of the Arduino’s analog pins. But to do that we need a fixed resistor (not changing) that we can use for that comparison (We are using a 22K resistor). This is called a voltage divider and divides the 5v between the flex sensor and the resistor.
The analog read on your arduino is basically a voltage meter. at 5V (its max) it would read 1023, and at 0v it read 0. So we can measure how much voltage is on the flex sensor using the analogRead and we have our reading.
The amount of that 5V that each part gets is proportional to its resistance. So if the the flex sensor and the resistor have the same resistance, the 5V is split evenly (2.5V) to each part. (analog reading of 512)
Reference
http://bildr.org/2012/11/flex-sensor-arduino/
Pin Configuration
Arduino | Sensor |
5V, A0 | Flex Pin 1 divided by 22k ohm resistor |
GND | Flex Pin 2 |
int flexSensorPin = A0; //analog pin 0 void setup(){ Serial.begin(9600); } void loop(){ int flexSensorReading = analogRead(flexSensorPin); Serial.println(flexSensorReading); delay(1000); //just here to slow down the output for easier reading }