Here's the original sketch from Sparkfun: // 47k resistor, and enter them below: const float VCC = 4.98; // Measured voltage of Ardunio 5V line const float R_DIV = 47500.0; // Measured resistance of 3.3k resistor // Upload the code, then try to adjust these values to more // accurately calculate bend degree. const float STRAIGHT_RESISTANCE = 37300.0; // resistance when straight const float BEND_RESISTANCE = 90000.0; // resistance at 90 deg void setup() { Serial.begin(9600); pinMode(FLEX_PIN, INPUT); } void loop() { // Read the ADC, and calculate voltage and resistance from it int flexADC = analogRead(FLEX_PIN); float flexV = flexADC * VCC / 1023.0; float flexR = R_DIV * (VCC / flexV - 1.0); Serial.println("Resistance: " + String(flexR) + " ohms"); // Use the calculated resistance to estimate the sensor's // bend angle: float angle = map(flexR, STRAIGHT_RESISTANCE, BEND_RESISTANCE, 0, 90.0); Serial.println("Bend: " + String(angle) + " degrees"); Serial.println(); delay(500); }
Allweneedtoknow. Watch my video 'Relay for beginners'. In that I have connected a relay to an arduino. If you want your flex sensor to be the input, you can connect it to one of the arduino pins say pin X, and declare pin X as input in your code. Then you can write a simple code to say: "if the input from flex sensor (pin X)is high then activate pin Y", and you can connect pin Y to relay. Hope this helps.
I‘m new to the topic but really interested, thank you so freaking much! This actually is exactly the topic I searched for. Can you maybe tell me if you got the data via a raspberry pi and is that python on your pc, or a whole different thing? Thank you so much!
The light will still be OFF only since the fingers are further bent which increases the resistance of the flex sensor and thereby decreases the voltage.
With all due respect, the way you explain is misguiding about the working principle of flex sensors. When the resistive coating layer bends backward, it is extension. It further decreases the resistance of the sensor. This sensor is supposed to work based on flexion which increases the resistance. The movement you do here is extension which further decreases the resistance from standard value 25 kilo ohms and making the LED to glow.