Or, alternatively:
Code:
pwmxx = (127 + (127*p1_sw_top) - (127*p1_sw_trig));
,
Replace xx with the pwm output you'll be using for the motor. In this case, pressing p1_sw_top will make the motor go full forward, p1_sw_trig will make it full reverse, and pressing both will do nothing.
