Esempio n. 1
0
        /// <summary>
        /// Create an instance of the ULN2003 driver (currently only supports 28BYJ step motor)
        /// </summary>
        public ULN2003(int IN1pin, int IN2pin, int IN3pin, int IN4pin, ULN2003Enums motorType = ULN2003Enums.STEP_28BYJ)
        {
            if (motorType == ULN2003Enums.Other)
            {
                IsSupported = false;
            }
            else
            {
                var gpio = GpioController.GetDefault();
                if (gpio != null)
                {
                    IN1 = gpio.OpenPin(IN1pin);
                    IN2 = gpio.OpenPin(IN2pin);
                    IN3 = gpio.OpenPin(IN3pin);
                    IN4 = gpio.OpenPin(IN4pin);

                    IN1.SetDriveMode(GpioPinDriveMode.Output);
                    IN2.SetDriveMode(GpioPinDriveMode.Output);
                    IN3.SetDriveMode(GpioPinDriveMode.Output);
                    IN4.SetDriveMode(GpioPinDriveMode.Output);

                    SetGPIOWrite(0, 0, 0, 0);

                    SetStepSequences(motorType);

                    SafeBreakMe = new SafeBreak();
                    SafeBreakMe.PropertyChanged += SafeBreakMe_PropertyChanged;

                    IsInitialized = true;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create an instance of the ULN2003 driver (currently only supports 28BYJ step motor)
        /// </summary>
        public ULN2003(IOPi bus, byte pin1, byte pin2, byte pin3, byte pin4, ULN2003Enums motorType = ULN2003Enums.STEP_28BYJ)
        {
            if (motorType == ULN2003Enums.Other)
            {
                IsSupported = false;
            }
            else
            {
                Bus    = bus;
                IN1pin = pin1;
                IN2pin = pin2;
                IN3pin = pin3;
                IN4pin = pin4;
                Bus.SetPinDirection(IN1pin, false);
                Bus.SetPinDirection(IN2pin, false);
                Bus.SetPinDirection(IN3pin, false);
                Bus.SetPinDirection(IN4pin, false);
                //IN1 = gpio.OpenPin(IN1pin);
                //IN2 = gpio.OpenPin(IN2pin);
                //IN3 = gpio.OpenPin(IN3pin);
                //IN4 = gpio.OpenPin(IN4pin);

                //IN1.SetDriveMode(GpioPinDriveMode.Output);
                //IN2.SetDriveMode(GpioPinDriveMode.Output);
                //IN3.SetDriveMode(GpioPinDriveMode.Output);
                //IN4.SetDriveMode(GpioPinDriveMode.Output);

                SetGPIOWrite(false, false, false, false);

                SetStepSequences(motorType);

                SafeBreakMe = new SafeBreak();
                SafeBreakMe.PropertyChanged += SafeBreakMe_PropertyChanged;

                IsInitialized = true;
            }
        }