change pwm control to function. call from processing thread