I suggest you put regulator valves on both ends of the pneumatic piston itself and mechanically adjust the amount of air going in.
I don't know of a way to do it via code, but this is the way I think most teams would do it.
Looks like this:
http://www.andymark.com/product-p/am-2032.htm
The dial lets you adjust the speed of air coming through the valve
__________________
FTC Teams 5257, 6568 & FRC Team 3992
Eagles Robotics Xperience
2014 FTC WORLD CHAMPIONS
14 Trophies in 3 Years