Can you please help me find a detailed datasheet of these types of sensors?
I am bending my fingers from straight to almost 90°. And then I am finding the difference between the values given by analogRead().
Lets say flex1=present value of finger-value at stability. What are is tge situation that would give me a negative result and what is the situation that would give me a positive result?
Any help for the second question?
In which situations will my flex sensor values from analogRead() taken at stability and after bending will the result be positive and in which will it be negative?
Can you please help me?
The value returned by analogRead() will never be negative.
I think I didnt phrase it correctly. I meant after the values are being returned they are being subtracted. And so which situations will make the difference positive and negative
I meant after the values are being returned they are being subtracted.
Subtracted from what?
And so which situations will make the difference positive and negative
If the value read is greater than the value that it is subtracted from, the result will be negative.
If the value read is less than the value that it is subtracted from, the result will be positive.
Nothing mysterious about that.
What is mysterious is why you won't post any code or explain what you are doing.
x_val = checkstabiliy(A2);
y_val = checkstabiliy(A3);
FLEX_VAL = checkstabiliy(A0);
FLEX_VAL1 = checkstabiliy(A1); // This returns a value of sensor when its stable(straight) from analogRead()
acc_x = analogRead(A2); //this is at bending position
x = acc_x - x_val;//finding the difference.
acc_y = analogRead(A3);
y = acc_y - y_val;
f_val = analogRead(A0);
f = f_val - FLEX_VAL;
f_val1 = analogRead(A1);
f1 = f_val1 - FLEX_VAL1;
if (((f1 < -40 ) || (f1 > 40)) && ((f < -40 ) || (f > 40)))
send_data += '1';
So im wondering about the conditions in the if statement. Because, if it's only bending one way shouldnt it either only be negative or only be positive? Thats why im asking about which situation gives what
Since that code doesn't compile, the answer is simple: Your results will be neither positive nor negative.
So im wondering about the conditions in the if statement.
Print the various values for yourself and see what results in positive values in the undefined variables.
Have you tried using the centre value as your zero point (value at stability ) and mapping the values either side of that to be positive and negative.
It does sound like that's what you need to do to convert a scale of lets say 0 to 1023 to a scale divided either side of 512.
But seeing as a finger doesn't go all the way back you might want to change the map to reflect that
Please keep all related posts in a single topic where possible, as jumping around for the same poster with almost the same question is frowned upon !
Any help for the second question?
How are you connecting the sensor to your Arduino? Do you have a schematic you can share? Have you written a code that uses this sensor? I would avoid negative numbers if possible. analogRead() will return a value from 0-1023, so there will only ever be 1024 possible values returned. Setting up your curcuit so that you can take advantage of the internal voltage reference will make your setup more flexible with varying power sources, ideally with max resistance (180 degrees) being 0 and min resistance (unflexed) giving 1023, which would give you the highest possible resolution.
@li16, do not cross-post. Threads merged.