Intenté hacer que esto se compile, pero sigue recibiendo el siguiente error:
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected ')' before 'int'
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected ')' before 'int'
// Receiver Code
#include <ServoTimer2.h>
ServoTimer2 servosteer; // create servo object to control a servo
ServoTimer2 servospeed; // create servo object to control a servo
//MEGA pin 23 receive pin - displays characters sent by RF
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
servosteer.attach(3); // attaches the servo on pin 25 to the servo object
servospeed.attach(4); // attaches the servo on pin 27 to the servo object
// lcd.init();
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
vw_set_rx_pin(8);
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
//invalid message length must be S/B/F/L/R + number (max 3 digits)
if (buflen < 3 || buflen > 5)
return;
digitalWrite(13, true); // Flash a light to show transmitting
char val[buflen]; //Same as buf, last char will be used for null terminator
memset(val, '/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected ')' before 'int'
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:111: error: expected ')' before 'int'
// Receiver Code
#include <ServoTimer2.h>
ServoTimer2 servosteer; // create servo object to control a servo
ServoTimer2 servospeed; // create servo object to control a servo
//MEGA pin 23 receive pin - displays characters sent by RF
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
servosteer.attach(3); // attaches the servo on pin 25 to the servo object
servospeed.attach(4); // attaches the servo on pin 27 to the servo object
// lcd.init();
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
vw_set_rx_pin(8);
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
//invalid message length must be S/B/F/L/R + number (max 3 digits)
if (buflen < 3 || buflen > 5)
return;
digitalWrite(13, true); // Flash a light to show transmitting
char val[buflen]; //Same as buf, last char will be used for null terminator
memset(val, '%pre%', sizeof(val));
//Copy value from string i.e. 213 from R213 into separate string
strncpy(val, (char *)buf + 1, buflen - 1);
//convert string containing value to integer e.g. "213" to 213.
int VAL = atoi ( val );
switch (buf[0]) {
case 'X': //Deadmans finger stop all
Serial.print("Deadmans finger");
servospeed.write(1500);
break;
case 'P':
Serial.print("Pitch ");
Serial.println(VAL);
servospeed.write(544+VAL*10);
break;
case 'R':
Serial.print("Roll ");
Serial.println(VAL);
servosteer.write(544+VAL*10);
break;
default:
break;
}
}
digitalWrite(13, false); // Flash a light to show transmitting
}
', sizeof(val));
//Copy value from string i.e. 213 from R213 into separate string
strncpy(val, (char *)buf + 1, buflen - 1);
//convert string containing value to integer e.g. "213" to 213.
int VAL = atoi ( val );
switch (buf[0]) {
case 'X': //Deadmans finger stop all
Serial.print("Deadmans finger");
servospeed.write(1500);
break;
case 'P':
Serial.print("Pitch ");
Serial.println(VAL);
servospeed.write(544+VAL*10);
break;
case 'R':
Serial.print("Roll ");
Serial.println(VAL);
servosteer.write(544+VAL*10);
break;
default:
break;
}
}
digitalWrite(13, false); // Flash a light to show transmitting
}