static Motors() { PWM.SetDesiredFrequency(6000); M1PWM = PWM.OpenChannel(FEZ.PwmChannel.Controller3.D9); M1PWM.Stop(); M1PWM.SetActiveDutyCyclePercentage(0.1); M1PWM.Start(); M2PWM = PWM.OpenChannel(FEZ.PwmChannel.Controller3.D10); M2PWM.Stop(); M2PWM.SetActiveDutyCyclePercentage(0.1); M2PWM.Start(); M1DIR = GpioController.GetDefault().OpenPin(FEZ.GpioPin.D7); M1DIR.SetDriveMode(GpioPinDriveMode.Output); M1DIR.Write(GpioPinValue.High); M2DIR = GpioController.GetDefault().OpenPin(FEZ.GpioPin.D8); M2DIR.Write(GpioPinValue.High); M2DIR.SetDriveMode(GpioPinDriveMode.Output); }
public static void Move(double LeftSpeed, double RightSpeed) { if (RightSpeed < 0) { M1DIR.Write(GpioPinValue.High); } else { M1DIR.Write(GpioPinValue.Low); } if (LeftSpeed < 0) { M2DIR.Write(GpioPinValue.High); } else { M2DIR.Write(GpioPinValue.Low); } M1PWM.SetActiveDutyCyclePercentage(Math.Abs(RightSpeed) / 100); M2PWM.SetActiveDutyCyclePercentage(Math.Abs(LeftSpeed) / 100); }