Seperate a value in arduino

Using the same sensor value for both seems like a typo. You should just add your second "gap" as a parameter to this function rather than computing it within the function.

Also, you don't appear to be "slowing" down since you are not doing any PWM, just turning pins HIGH/LOW.