I’m currently using in my project a pressure sensor Force Sensitive Resistor 0.5" - SEN-09375 - SparkFun Electronics an arduino Uno and a standard 0-180 degree rotation servo. I’m a beginner and I want to make a program that at the beginning the servo position will be 0o but if force is applied to the sensor the servo will start moving until the force applied to the sensor becomes 0.
Any help will be appreciated!
The servo/pot example code might be a starting point for you.
Thank's for you reply,but I have tried this...
As i noted in my first post i want something different than this.
HarisD:
Thank's for you reply,but I have tried this...
As i noted in my first post i want something different than this.
Then you need to study up on FSR circuits. The The FSR can be part of a voltage divider circuit, which is basically what a pot is.
Can you provide me some links or quidelines in order to start some research??
Hi...
This is a similar thing I did recently. I used an LDR mounted on the horn of the servo so it swivelled until it found light then stopped. Then if I moved the light so it was in the dark it started up again. That's pretty much the same as you pressing the FSR or not. By trial end error I used a threshold of 500 for it being dark or light...
I've never used an FSR but afaik it's just got 5v on one side, a resistor to ground on the other, and the junction of the FSR and resistor goes to your analog in pin... so it's the same as my LDR. See attached Fritzing pic (if I managed to attach it, that is....) (Edit: Have a look at the FSR Tutorial at LadyAda.)
Anyway, hope this helps:
/* Idea here is to have LDR mounted on servo horn
and have servo sweep when LDR reads dark, to
move LDR so it finds a light area
*/
// sort the servo
#include <Servo.h>
Servo Jimservo;
int JimservoPos= 90;
int JimservoClick = 15; //how many degrees per move
//sort the LDR
int LDRpin = A0;
int LDRvalue;
int LDRthreshold = 500; //value under which it seeks
void setup() {
pinMode(LDRpin, INPUT);
Jimservo.attach(3);
Jimservo.write(90);
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
}
void loop() {
if (LDRvalue < LDRthreshold) //then it's dark...
{
Jimservo.write(JimservoPos);
Serial.print(JimservoClick);
Serial.print("\t");
Serial.println(JimservoPos);
JimservoPos = JimservoPos + JimservoClick;
JimservoPos = constrain(JimservoPos, 0, 180);
if (JimservoPos < 2 || JimservoPos > 178) //change direction
{
JimservoClick = JimservoClick * (-1);
Serial.println("Changing direction");
}
}
}