//TMI8549电机驱动芯片/TMI8549 motor driver chip
#define ENA   5   //使能端，可使用PWM调速/Enable, PWM can be used
#define INT1  7   //IN1输入端 input
#define INT2  8   //IN2输入端 input

int Speed_sit = 150;

void setup()  {
  Serial.begin(9600);
  pinMode(ENA,OUTPUT);
  pinMode(INT1,OUTPUT);
  pinMode(INT2,OUTPUT);
}

void loop() {
  //INT1,INT2输出控制逻辑
  //INT1   INT2   OUT1    OUT2    OUT3    OUT4
  //0      0      1       0       1       0     前进
  //1      0      0       1       1       0     左转
  //1      1      0       1       0       1     后退 
  //0      1      1       0       0       1     右转  
  analogWrite(ENA,Speed_sit);   //对ENA输入0~255的PWM波进行调速
  digitalWrite(INT1,LOW);   //前进 forward
  digitalWrite(INT2,LOW);
  delay(3000);

  digitalWrite(INT1,HIGH);  //后退 back
  digitalWrite(INT2,HIGH);
  delay(3000);

  digitalWrite(INT1,HIGH);  //左转 turn left
  digitalWrite(INT2,LOW);
  delay(3000);

  digitalWrite(INT1,LOW);   //右转 turn right 
  digitalWrite(INT2,HIGH);
  delay(3000);
}
