The code in my arduino mega:
void setup(){
Serial.begin(57600);
Serial1.begin(57600);
Wire.begin();
SLAVE_I2C_INIT();
HMC.init();
}
void loop()
{
int test1;
if (Serial1.available() > 0)
{
test1= Serial1.read();
}
Serial.print("B");
Serial.print(test1);
Serial.println();
delay(400);
int kleinste=3;
int check=0;
if (read_IRsensor_range(afst0) <40) //indien afstand langs voor
{ kleinste =0;
check=1;
}
if (read_IRsensor_range(afst1) <40)// afstand links
{ kleinste=1;
check=1;
}
if (read_IRsensor_range(afst2)<40)// afstand rechts
{ kleinste=2;
check=1;
}
if (read_IRsensor_range(afst3)<40) //afstand achter
{ kleinste=3;
check=1;
}
if (check==0){ kleinste=3; }
Serial1.print(kleinste);
Serial1.println();
Code on my blimpduiono:
void setup()
{
Serial.begin(57600);
Init_RC();
Init_LEDs();
Init_IRs();
init_ultrasonic();
Init_motors();
}
void loop()
{
if (Serial.available() > 0)
{
au_compare= Serial.read();
}
Serial.print((int)raw_ultrasonic());
Am sending the data serial from a blimpduino to my arduino mega and vica versa. Thats Serial1 on my mega, Serial on my blimpduino. Then from my mega with Xbee (Serial) to my computer.
When i connect my computer directly to my blimpduino i got the data that i want the mega to receive but doesn't work when i try to get the data from the xbee's. Do i read in my data correctly? Or is it someting els that i do wrong