added new code for controlling h-bridge