Need help with controlling a motor(Ultra Noob)

Hey! I finally sat down and tried myself at arduino coding but i need some help.

I made a motorised reacher/grabber for folks in wheelchairs etc.. And have trouble making the code work, i made the mechanism first and postponed the coding to now.

I have a VNH5019 Motor Driver connected to a dc motor and a push button.

This is what i want it to do:

Press button once

Motor drives until certain current is read (driver can read current)

Motor brakes

Button is pressed again

Motor reverses until certain current is read

I use this libary GitHub - pololu/dual-vnh5019-motor-shield: Arduino library for the Pololu Dual VNH5019 Motor Driver Shield

Can anyone help me accomplish this code? Would really appreciate it!

Post the code that you have tried. Describe what the code actually does and how that differs from what you want it to do. Which Arduino board are you using? Post a schematic of your project's wiring.

If the operator is watching the current , is there anything for the Arduino to do ?

Anyway ...- you can measure the current with the voltdrop across a small resistor in the ground leg of the motor. This won’t work ( easily) however if you want to control the motor speed with a pwm output .

Learn about state machines - here you have several states and transitions that loop() will have to
check for.

If the state is running forward then a certain current reading will transistion to the stopped state,
ditto for backwards (a larger current reading perhaps, if you are backing out of a jam?).

The push button transitions to the relevant moving state.