Доброго времени суток! Народ! кто сталкивался и может что то посоветовать? Ситуация такая: Я собрал два шаговых двигателя и дальномер на платформе Arduino Uno и все прекрасно работает. Код ниже. Дальше решил уменьшить размеры и поставить на Micro, но система выдает ошибку. Вот понять не могу в чем разница, почему на Uno работает, а на Micro не хочет. Буду благодарен за совет. Всем добра! Ошибка: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// dalnomer_rotate:5: error: expected ',' or '...' before numeric constant C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:221:23: note: in expansion of macro 'rx' bool MSC_Data(uint8_t rx,uint8_t tx); ^ expected ',' or '...' before numeric constant /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Весь код: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // dla podkluchenia k kompu (cherez radiokanal ili naprjamik...) #include <SoftwareSerial.h> //Include the software serial library #define rx 2 //define what pin rx is going to be #define tx 3 //define what pin tx is going to be SoftwareSerial myserial(rx, tx); //define how the soft serial port is going to work. /// PWM 3, 5, 6, 9, 10, 11 int motor1_a_m = 4; //Arduino pin 4 to control motor 1 obmotka a current direction int motor1_b_m = 7; //Arduino pin 7 to control motor 1 obmotka b current direction int motor1_a_e = 5; //Arduino pin 5 to control motor 1 obmotka a current value int motor1_b_e = 6; //Arduino pin 6 to control motor 1 obmotka b current value int motor2_a_m = 8; //Arduino pin 8 to control motor 2 obmotka a current direction int motor2_b_m = 11; //Arduino pin 11 to control motor 2 obmotka b current direction int motor2_a_e = 9; //Arduino pin 9 to control motor 2 obmotka a current value int motor2_b_e = 10; //Arduino pin 10 to control motor 2 obmotka b current value unsigned short i,j,k,kk; unsigned char step1,step2; char computerdata[20]; //ot rompa prihodit 20 bytov (nu poka ot fonarja) char sensordata[8]; //ot dalnomera prihodit 8 bytov byte computer_bytes_received=0; //We need to know how many characters bytes have been received byte sensor_bytes_received=0; //We need to know how many characters bytes have been received char message_to_PC[19]; //Char pointer used in string parsing void setup() { pinMode(motor1_a_m, OUTPUT); pinMode(motor1_b_m, OUTPUT); pinMode(motor2_a_m, OUTPUT); pinMode(motor2_b_m, OUTPUT); analogWrite(motor1_a_e,255); // poka ne microshag analogWrite(motor1_b_e,255); // poka ne microshag analogWrite(motor2_a_e,255); // poka ne microshag analogWrite(motor2_b_e,255); // poka ne microshag step1=0; step2=0; Serial.begin(19200); //Set the hardware serial port to 19200 myserial.begin(19200); //Set the soft serial port to 19200 i=Serial.available(); for (j=0;j<i;j++) {computerdata[0]=Serial.read();} i=myserial.available(); for (j=0;j<i;j++) {computerdata[0]=myserial.read();} } void loop() { computer_bytes_received=Serial.available(); i=Serial.available(); for (j=0;j<i;j++) {computerdata[0]=Serial.read();} if(computer_bytes_received!=0) {// chto-to prishlo iz kompa // poka parsit ne budem: polnij oborot po 1 i polnij po 2 computer_bytes_received=0; //sbrosim flag prihoda posle parsinga for (i=0;i<400;i++) { for (j=0;j<400;j++) { read_sence(); send_result(i,j); step_1(); } step_2(); } } } void read_sence() { myserial.print("D"); while (myserial.available()==0) {};//zhdem prihoda ot dalnomera delay(9); //podojdat 15 bait kk=0; while(myserial.available() > 0) // esli oshibka izmerenia, to tam ne 15 bait { sensordata[kk]=myserial.read(); kk++; } } void send_result(short i_i,short j_j) { message_to_PC[0]=(i_i/100+0x30); i_i=i_i%100; message_to_PC[1]=(i_i/10+0x30); i_i=i_i%10; message_to_PC[2]=(i_i+0x30); message_to_PC[3]=(0x20); //probel message_to_PC[4]=(j_j/100+0x30); j_j=j_j%100; message_to_PC[5]=(j_j/10+0x30); j_j=j_j%10; message_to_PC[6]=(j_j+0x30); message_to_PC[7]=(0x20); //probel message_to_PC[8]=sensordata[1]; message_to_PC[9]=sensordata[2]; message_to_PC[10]=sensordata[3]; message_to_PC[11]=sensordata[4]; message_to_PC[12]=sensordata[5]; message_to_PC[13]=sensordata[6]; message_to_PC[14]=sensordata[7]; message_to_PC[15]=sensordata[8]; message_to_PC[16]=0x20; message_to_PC[17]=13; message_to_PC[18]=10; for (k=0;k<19;k++){ Serial.print(message_to_PC[k]);} } void step_1() { //sija funczia delaet shag motorom1 switch (step1) { case 0: // a+ b+ digitalWrite(motor1_a_m,HIGH); digitalWrite(motor1_b_m,HIGH); step1=1; break; case 1: // a+ b- digitalWrite(motor1_a_m,HIGH); digitalWrite(motor1_b_m,LOW); step1=2; break; case 2: // a- b- digitalWrite(motor1_a_m,LOW); digitalWrite(motor1_b_m,LOW); step1=3; break; case 3: // a- b+ digitalWrite(motor1_a_m,LOW); digitalWrite(motor1_b_m,HIGH); step1=0; break; } } void step_2() { //sija funczia delaet shag motorom2 switch (step2) { case 0: // a+ b+ digitalWrite(motor2_a_m,HIGH); digitalWrite(motor2_b_m,HIGH); step2=1; break; case 1: // a+ b- digitalWrite(motor2_a_m,HIGH); digitalWrite(motor2_b_m,LOW); step2=2; break; case 2: // a- b- digitalWrite(motor2_a_m,LOW); digitalWrite(motor2_b_m,LOW); step2=3; break; case 3: // a- b+ digitalWrite(motor2_a_m,LOW); digitalWrite(motor2_b_m,HIGH); step2=0; break; } }
Код (C++): #define rx 2 //define what pin rx is going to be #define tx 3 //define what pin tx is going to be С учетом этих дефайнов выражение Код (C++): bool MSC_Data(uint8_t rx,uint8_t tx); превращается в Код (C++): bool MSC_Data(uint8_t 2,uint8_t 3); и компилятору это очень не нравится. Когда вставляете код на форум, нажимайте Ctrl+T в Arduino IDE и пользуйтесь тэгом CODE.