Arduino Robot Arm


#1

Hi there, I’m working through the circuit.io tutorial over on Instructables. I’ve wired correctly (I think) and tried to match the components listed. I’ve downloaded the code and swapped in the Github firmware. I’ve got two servos working and responding to the joystick and the button press is registering on the serial monitor. However, nothing happens to the gripper servo, it doesn’t move at all. It is definitely not a malfunctioning servo i.e. it goes to its start position. I’ve double checked the wiring and the pin definitions. The only thing I can think is that there is a bug in the code or my joystick requires different coding. It says robotlinking on it and it has the same number of outputs etc. Any thoughts what might be going wrong?


#2

Hi Andrew

Could you share the circuito project with us, and maybe post your ino code as well so we can check it out?

Thanks
Bernhard


#3

Hello Bernhard,

Its this project:


https://www.circuito.io/app?components=9442,10333,10333,10333,11021,611984

The code I’m using is here: https://drive.google.com/file/d/1Ku5yLEugJMYz7hepEUVwLjP0Q_Ks74Or/view?usp=sharing and the specific issue I’m getting is the link between the joystick button press and the servo moving - nothing is happening to the gripper.


#4

Looks like you have a bug there Andrew:

if (joystickSW)
{
if(gripperState == 0)
  gripper.write(gripperMaxPosition);  
else
  gripper.write(gripperMinPosition);  
// Update gripper state
gripperState = !gripperState;  
}

You should update the gripperState regardless of whether you write max/min position to it. So replace the above with the following:

if (joystickSW)
{
    if(gripperState == 0)
      gripper.write(gripperMaxPosition);  
    else
      gripper.write(gripperMinPosition);  
}

// Update gripper state
gripperState = !gripperState;

#5

Many thanks @bhofmann. That seemed to do it. For some reason I also had to change the gripper minimum position too:

const int gripperMinPosition = 20;

and add an extra delay inside the if else statement

// On each joystick press, toggle the gripper’s state
if (joystickSW)
{
if(gripperState == 0)
gripper.write(gripperMaxPosition);
else
gripper.write(gripperMinPosition);
delay(200);
}

delay(20);

#6

Glad I could help. Have fun! :smiley: