Hello,
for my current project i need a servo gripper. I have build a strong gripper using some 3d prints and a rc servo from Amazon.
I'm using a Esp32 and a breadboard 5V power supply.
The mechanical system seems to work just fine. However I have problems programming it.
My goals for the gripper:
-grip as hard on the object, object should be of varying size
-return to a "normal" position, which is the open position
Here's a video of it using the code i wrote: https://youtube.com/shorts/QC1ttSWhqTU?feature=share
And here's the code:
#include <ESP32Servo.h>
Servo gripperServo; // Create a Servo object
const int gripperPin = 25; // Pin connected to the servo signal wire
const int openAngle = -250; // Angle to fully open the gripper
const int closeAngle = 10; // Angle to fully close the gripper
const int holdTime = 2000; // Time in milliseconds to hold the position
const int minPulseWidth = 500; // Minimum pulse width in microseconds
const int maxPulseWidth = 2500; // Maximum pulse width in microseconds
int pos;
// Define min and max pulse widths
void setup() {
// Attach the servo on pin 13 to the servo object with min and max pulse widths
gripperServo.attach(gripperPin, minPulseWidth, maxPulseWidth);
gripperServo.write(0);
}
void loop() {
// Open the gripper as far as possible and hold for a few seconds
gripperServo.write(openAngle);
delay(holdTime);
// Close the gripper as far as possible and hold for a few seconds
gripperServo.write(closeAngle);
delay(holdTime);
// Repeat the cycle
}
Does anyone have an idea on how to tackle my problem and help me?
Thanks