使用arduino控制转接板原理如下

arduino的esp32控制代码如下:
int IOR1=33;
int IOR2=32;
int IOR3=25;
int IOR4=15;
int IO1=2;
int IO2=4;
int IO3=21;
int IO4=22;
///////////////////////////电机控制程序
void MX_motorControl(unsigned char MX_motorControl_port,unsigned char MX_motorControl_function,char MX_motorControl_content1,long MX_motorControl_content2)
{ byte MX_motorControl_send[7];//创建变量,用于发送数据
digitalWrite(MX_motorControl_port,LOW);//通讯标志位置低,通知开始发送
MX_motorControl_send[0]=0xa5; //发送起始位
MX_motorControl_send[1]=MX_motorControl_function; //功能位
MX_motorControl_send[2]=MX_motorControl_content1;//内容位1
MX_motorControl_send[3]=MX_motorControl_content2>>24;//内容位2
MX_motorControl_send[4]=MX_motorControl_content2>>16;
MX_motorControl_send[5]=MX_motorControl_content2>>8;
MX_motorControl_send[6]=MX_motorControl_content2;
MX_motorControl_send[7]=MX_motorControl_send[1]^MX_motorControl_send[2]^MX_motorControl_send[3]^MX_motorControl_send[4]^MX_motorControl_send[5]^MX_motorControl_send[6];//校验位
Serial2.write(MX_motorControl_send[0]);Serial2.write(MX_motorControl_send[1]);
Serial2.write(MX_motorControl_send[2]);Serial2.write(MX_motorControl_send[3]);
Serial2.write(MX_motorControl_send[4]);Serial2.write(MX_motorControl_send[5]);
Serial2.write(MX_motorControl_send[6]);Serial2.write(MX_motorControl_send[7]);//发送全部内容
delay(1);//等待1ms
digitalWrite(MX_motorControl_port,HIGH); //通讯标志位置高,通知结束发送
}
void setup() {
pinMode(IOR1, OUTPUT);
Serial2.begin(115200);
}
void loop() {
MX_motorControl(IOR1,10,-10,0);
delay(1000);
MX_motorControl(IOR1,10,10,0);
delay(1000);
}