DCDC3PA三轮小车套件降压

功能介绍

3PA小车平台的组装非常容易,只需要按照以下步骤一步步安装就行了。

STEP1:组装小车

参照安装说明

注意事项:

1. 在安装说明中没有说明电机电源线连接,建议安装前先将电机的电源线焊接好。便于之后安装。

2. 安装完底盘之后,按下图连接电机线和电源线。

STEP2:调试电机

' 下载电机调试代码'

    int speedPin_M1 = 5;     //M1 Speed Control
    int speedPin_M2 = 6;     //M2 Speed Control
    int directionPin_M1 = 4;     //M1 Direction Control
    int directionPin_M2 = 7;     //M1 Direction Control

    void setup(){

    }

    void loop(){
        carAdvance(100,100);
        delay(1000);
        carBack(100,100);
        delay(1000);
        carTurnLeft(250,250);
        delay(1000);
        carTurnRight(250,250);
        delay(1000);
    }

    void carStop(){                 //  Motor Stop
      digitalWrite(speedPin_M2,0);
      digitalWrite(directionPin_M1,LOW);
      digitalWrite(speedPin_M1,0);
      digitalWrite(directionPin_M2,LOW);
    }

    void carAdvance(int leftSpeed,int rightSpeed){         //Move forward
      analogWrite (speedPin_M2,leftSpeed);              //PWM Speed Control
      digitalWrite(directionPin_M1,HIGH);
      analogWrite (speedPin_M1,rightSpeed);
      digitalWrite(directionPin_M2,HIGH);
    }

    void carBack(int leftSpeed,int rightSpeed){       //Move backward
      analogWrite (speedPin_M2,leftSpeed);
      digitalWrite(directionPin_M1,LOW);
      analogWrite (speedPin_M1,rightSpeed);
      digitalWrite(directionPin_M2,LOW);
    }

    void carTurnRight(int leftSpeed,int rightSpeed){           //Turn Right
      analogWrite (speedPin_M2,leftSpeed);
      digitalWrite(directionPin_M1,LOW);
      analogWrite (speedPin_M1,rightSpeed);
      digitalWrite(directionPin_M2,HIGH);
    }
    void carTurnLeft(int leftSpeed,int rightSpeed){          //Turn Left
      analogWrite (speedPin_M2,leftSpeed);
      digitalWrite(directionPin_M1,HIGH);
      analogWrite (speedPin_M1,rightSpeed);
      digitalWrite(directionPin_M2,LOW);
    }

上电后发现,如果发现效果与代码不匹配,可以对代码做一下微调整。直到匹配为止,才进行下一步。