In the programming how do I make the Motors idle without them having to move any or very little. As to keep the claws having pressure on a certain item. So if I let go of the button it doesn’t lose power and drop the item. And please respond with up to date code.
The usual approach is to send a small control value to the motors, for example, if you had been using a value of 127 to close the claw, then send a value in the range of 10-25 as a “hold” value. To decide when to send the smaller value either use feedback from the claw such an an encoder or potentiometer and detect when the claw has stopped moving or just use a timer. Pseudo code for that may be as follows (or at least something like this).
if button to close claw is pressed
if timeout has happened
send small value to claw motor
else
send large value to claw motor
end if
else
if button to open is pushed
send open value to claw motor
reset timer
else
if no buttons are pressed and timeout has happened
send small close value to claw motor
end if