bleep bloop.

sorry, i know nothing of code for microcontrollers.

i should learn one day.
but I think you have the right idea.
the coil still runs on 24 volts (or wahtever) but you vary the duty cycle to adjust the grip.
depending on the claw, you may have to go way down to like a 20% on 80% off in order to see an appreciable difference in the strength.
using a 555 to drive the FET, the 555 timer chip is setup to flip on and off an output.... by turning up a pot you can make it flip on and off faster...say 1000 times a second....you can then turn the pot down so the output flips off and on maybe 250 times a second.
this output is connected to a FET that supplies current to the coil of the claw. more pulses means more "on time" and less pulses meant less "on time"
a more advanced circuit would vary the duty cycle of the output to shorten the "OFF" time and lengthen the "ON" time instead of simply having more pulses.
maybe this will help explain about this a little more better than me for your case...
https://www.arduino.cc/en/Tutorial/PWM