Sorry Disturb everyone
Dear friends
My use arduino due I / O for TX0 & RX0
Here is my program
int led = 13;
int id; // 馬達ID
int torg; // 轉距(0:max, 4:min)
int checksum; // 通訊協定
int tmp1, tmp2; // byte 數量
void setup()
{
pinMode(led,OUTPUT);
Serial.begin(115200); // 起始串列115200bps
while(!Serial){ // 等待通訊
;
}
id = 0;
torg = 2; // 轉距速度
digitalWrite(led,HIGH);
tmp1 = (torg << 5) | id; // 馬達速度及編碼號
tmp2 = 60; // 位置碼
checksum = (tmp1 ^ tmp2) & 0x7f; // 結束碼(馬達速度及編碼號XOR位置碼)
Serial.write(0xff); // 回傳編碼
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(5000); // 等待時間
}
void loop()
{
digitalWrite(led,HIGH);
tmp1 = (torg << 5) | id; //馬達速度及編碼號
tmp2 = 100; //位置碼
checksum = (tmp1 ^ tmp2) & 0x7f; //結束碼(馬達速度及編碼號XOR位置碼)
Serial.write(0xff); //回傳編碼
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(1000); //等待時間
digitalWrite(led,LOW);
tmp1 = (torg << 5) | id;
tmp2 = 200;
checksum = (tmp1 ^ tmp2) & 0x7f;
Serial.write(0xff);
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(1000);
digitalWrite(led,HIGH);
tmp1 = (torg << 5) | id;
tmp2 = 180;
checksum = (tmp1 ^ tmp2) & 0x7f;
Serial.write(0xff);
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(1000);
digitalWrite(led,LOW);
tmp1 = (torg << 5) | id;
tmp2 = 220;
checksum = (tmp1 ^ tmp2) & 0x7f;
Serial.write(0xff);
Serial.write(tmp1);
Serial.write(tmp2);
Serial.write(checksum);
delay(1000);
}
Ai motor have four pins inside the motor (V, TX, RX, G)
Motor TX -> DUE RX0
Motor reception -> DUE TX0
AI motor it can control, but not control another one
How do I modify my program use to DUE another pin for TX1, RX1, TX2, RX2, RX3, TX3 (pin)
I have 4 AI motor control
How to do modify to control 4 ai motor and use all TX RX pin?