/// <summary> /// Initializes four pins for motor driver /// </summary> /// <param name="Pin_MotorLeft_A">Left motor's Pin A.</param> /// <param name="Pin_MotorLeft_B">Left motor's Pin B.</param> /// <param name="Pin_MotorRight_A">Right motor's Pin A.</param> /// <param name="Pin_MotorRight_B">Right motor's Pin B.</param> public static void InitializePins(AvailableGpioPin Pin_MotorLeft_A, AvailableGpioPin Pin_MotorLeft_B, AvailableGpioPin Pin_MotorRight_A, AvailableGpioPin Pin_MotorRight_B) { // Initialize Gpio Controller GpioController MyGpioConroller = GpioController.GetDefault(); // If GpioPins are not null then make them first null to release old pins. // Check only one pin against null and if it is not then null all. if (MotorLeft_A != null) { MotorLeft_A = null; MotorLeft_B = null; MotorRight_A = null; MotorRight_B = null; } // Initialize Pins MotorLeft_A = MyGpioConroller.OpenPin((int)Pin_MotorLeft_A); MotorLeft_B = MyGpioConroller.OpenPin((int)Pin_MotorLeft_B); MotorRight_A = MyGpioConroller.OpenPin((int)Pin_MotorRight_A); MotorRight_B = MyGpioConroller.OpenPin((int)Pin_MotorRight_B); // Set Drive Mode MotorLeft_A.SetDriveMode(GpioPinDriveMode.Output); MotorLeft_B.SetDriveMode(GpioPinDriveMode.Output); MotorRight_A.SetDriveMode(GpioPinDriveMode.Output); MotorRight_B.SetDriveMode(GpioPinDriveMode.Output); // Set Current State _CurrentState = State.Stopped; }