public void SetDirection(SpinDirection direction) { Direction = direction; switch (direction) { case SpinDirection.Clockwise: DirectionPin.Write(GpioPinValue.High); break; case SpinDirection.CounterClockwise: DirectionPin.Write(GpioPinValue.Low); break; } }
public Drv8825(int directionPin, int enablePin, int stepPin) { var gpioController = GpioController.GetDefault(); DirectionPin = gpioController.OpenPin(directionPin); DirectionPin.Write(GpioPinValue.Low); DirectionPin.SetDriveMode(GpioPinDriveMode.Output); EnablePin = gpioController.OpenPin(enablePin); EnablePin.Write(GpioPinValue.Low); EnablePin.SetDriveMode(GpioPinDriveMode.Output); StepPin = gpioController.OpenPin(stepPin); StepPin.Write(GpioPinValue.Low); StepPin.SetDriveMode(GpioPinDriveMode.Output); }
public StepperMotor(int stepPinNumber, int dirPinNumber, long ticksPerSecond) { GpioController controller = GpioController.GetDefault(); StepPin = controller.OpenPin(stepPinNumber); DirectionPin = controller.OpenPin(dirPinNumber); StepPin.SetDriveMode(GpioPinDriveMode.Output); DirectionPin.SetDriveMode(GpioPinDriveMode.Output); SetDirection(SpinDirection.Clockwise); this.ticksPerSecond = ticksPerSecond; stopwatch = new Stopwatch(); stopwatch.Start(); Name = "Motor (" + stepPinNumber + ")"; }