Hello,
I install EasyTranfer_2way_wPot_Example and EasyTranfer_2way_wServo_Example on two Arduino due's.
And I use an Half Duplex hardware.
At first I thought it worked well, but sometimes after starting it doesn't go well.
I think I have a situation where both tx (transmit data) of the arduinos are active at the same time.
And that doesn't recover.
Like a response how I can solve this problem.
Or maybe an advice to use another library. ( I only want read and write in and outputs, and read and write a data register )
Thanks in advance,
Lenn.
EasyTranfer_2way_wPot_Example
=========================
#include <EasyTransfer.h>
EasyTransfer ETin, ETout;
struct RECEIVE_DATA_STRUCTURE{
int16_t buttonstate;
};
struct SEND_DATA_STRUCTURE{
int16_t buttonstate;
int16_t servoval;
};
RECEIVE_DATA_STRUCTURE rxdata;
SEND_DATA_STRUCTURE txdata;
void setup(){
Serial.begin(9600);
ETin.begin(details(rxdata), &Serial);
ETout.begin(details(txdata), &Serial);
pinMode(13, OUTPUT);
pinMode(12, INPUT_PULLUP);
}
void loop(){
txdata.servoval = analogRead(0);
if(!digitalRead(12))
txdata.buttonstate = HIGH;
else
txdata.buttonstate = LOW;
ETout.sendData();
for(int i=0; i<5; i++){
ETin.receiveData();
digitalWrite(13, rxdata.buttonstate);
delay(10);
}
delay(10);
EasyTranfer_2way_wServo_Example
=========================
#include <Servo.h>
#include <EasyTransfer.h>
//create two objects
EasyTransfer ETin, ETout;
Servo myservo;
struct RECEIVE_DATA_STRUCTURE{
int16_t buttonstate;
int16_t servoval;
};
struct SEND_DATA_STRUCTURE{
int16_t buttonstate;
};
RECEIVE_DATA_STRUCTURE rxdata;
SEND_DATA_STRUCTURE txdata;
void setup(){
Serial.begin(9600);
.
ETin.begin(details(rxdata), &Serial);
ETout.begin(details(txdata), &Serial);
pinMode(13, OUTPUT);
pinMode(12, INPUT_PULLUP);
myservo.attach(9);
}
void loop(){
if(!digitalRead(12))
txdata.buttonstate = HIGH;
else
txdata.buttonstate = LOW;
ETout.sendData();
for(int i=0; i<5; i++){
ETin.receiveData();
digitalWrite(13, rxdata.buttonstate);
myservo.write(map(rxdata.servoval, 0, 1023, 0, 179));
delay(10);
}
delay(10);
}