Exemple #1
0
        public Stepper_Motor(Motor_Hat controller, int motor, int steps = 200)
        {
            MC              = controller;
            revsteps        = steps;
            motornum        = motor;
            sec_per_step    = 0.1;
            steppingcounter = 0;
            currentstep     = 0;

            motor -= 1;

            if (motor == 0)
            {
                PWMA = 8;
                AIN2 = 9;
                AIN1 = 10;
                PWMB = 13;
                BIN2 = 12;
                BIN1 = 11;
            }
            else if (motor == 1)
            {
                PWMA = 2;
                AIN2 = 3;
                AIN1 = 4;
                PWMB = 7;
                BIN2 = 6;
                BIN1 = 5;
            }
            else
            {
                Console.WriteLine("MotorHAT Stepper must be between 1 and 2 inclusive");
                return;
            }
        }
Exemple #2
0
        public DC_Motor(Motor_Hat controller, int motor)
        {
            MC       = controller;
            motornum = motor;
            int pwm = 0, in1 = 0, in2 = 0;

            if (motor == 0)
            {
                pwm = 8;
                in2 = 9;
                in1 = 10;
            }
            else if (motor == 1)
            {
                pwm = 13;
                in2 = 12;
                in1 = 11;
            }
            else if (motor == 2)
            {
                pwm = 2;
                in2 = 3;
                in1 = 4;
            }
            else if (motor == 3)
            {
                pwm = 7;
                in2 = 6;
                in1 = 5;
            }
            else
            {
                Console.WriteLine("MotorHAT Motor must be between 1 and 4 inclusive");
                return;
            }
            PWMpin = pwm;
            IN1pin = in1;
            IN2pin = in2;
        }