Adjust gripper angle or pressure

Greetings all and happy Thanksgiving!

Please, I am trying to write a code to control the gripper closing force or angle according to a reading from a sensor ( I am not sure if only one sensor needed or two)
so the gripper servo will respond and go to the best closing angle which is enough to:

Hold tight the object
Lift the object for two seconds or so
put back the object
Release object
The serial monitor will display Force applied and adjusted gripper Angle continuously while dealing with each object

The gripper will expect another object ( I am trying to use three different sizes or weights) to gripp, hold and lift and put back so in this case the gripper will adjust to new angle or pressure. My gripper works between ~ 45 degrees (full open) to ~ 110 degrees (full close)

Please i need help with such a code. I could get a reading from sensors every time i press on them but i could not so far able to code the gripper adjustment around each object

Electronics:

I have one sensor attached to each gripper finger.
One servo for gripper
One servo to lift arm
Arduino Mega 2560 microcontroller
Interlink Electronics 0.5" Circular FSR
Interlink Electronics 1.5" Square FSR
Thank you so much. Your help will make much difference!

ZRobotics:
I could get a reading from sensors every time i press on them but i could not so far able to code the gripper adjustment around each object

What kind of readings are you getting from your FSR?

What code have you tried? What didn't work?

Make sure you read "How to use this forum", particularly item #7 about posting code.

Thank you DuaneDegn for your time to read my post.

I could read about 1000 when firmly press on the fsr.

Here is my test code

#include <Servo.h>

Servo s1;
Servo s2;

int pos;
int fsr = 15;     // pin for sensor and 10k resistor
int force;     // analog reading 

 
void setup() 
{
  Serial.begin(9600);
  s1.attach(8);   
  s2.attach(9);  
}
 
void loop()
{
 s2.write(45); //start gripper open
 delay(1000);
 s2.write(100);
   force = analogRead(fsr);  // FSR reading
  Serial.print("FSR reading = "); 
  Serial.println(force); // display fsr value when gripper close
  pos = map(force, 0, 1023, 45, 100); // relates force reading to degrees of gripper servo position
  Serial.print("Gripper Angle = ");
  Serial.println(pos); // gripper angle reading from pos
  delay(300);
if(force < 1 ){
  s2.write (90);

  if(force = 10){
    s2.write(85);

    if(force >18){
      s2.write(75);
    }
  }
}  
  s2.write(pos); // go to pos
  delay(250); // Delay 250 milliseconds 

s1.write(25); //the object will be lifted
  delay (3000);
  s1.write(0); // put down object
  delay (1000); 
}

Thank you in advance for suggestions

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Your other thread deleted.

  • Moderator

I am sorry Nick Gammon you are right I should have deleted the other one. I was confused where to correctly post it.

Thank you for the note.

Any time, buddy. :slight_smile: