Tanks. I will not use 10 sensor in the future because with 6 sensor all pin of the 328 is used but could you make me an example of your "constant value line numSoilSamples that is equal to 6" because i think i don't understand.
this is the modified code:
#include <EasyTransfer.h>
//create object
EasyTransfer ET;
struct SEND_DATA_STRUCTURE{
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
int soil[7];
};
//give a name to the group of data
SEND_DATA_STRUCTURE mydata;
void setup(){
Serial.begin(9600);
//start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
ET.begin(details(mydata), &Serial);
for(int i=2;i<14;i++){
pinMode(i,OUTPUT);
digitalWrite(i, LOW);
}
for(int i=0;i<6;i++){
pinMode(i,INPUT);
}
}
void loop(){
//send the data
for (int i=0;i<6;i++){
sensorRead(i);
ET.sendData();
}
}
void sensorRead(int sensor){
digitalWrite(sensor*2, HIGH);
digitalWrite(sensor*2+1, LOW);
delay(1000);
int val1 = analogRead(sensor-1);
digitalWrite(sensor*2, LOW);
digitalWrite(sensor*2+1, HIGH);
delay(1000);
int val2 = 1023 - analogRead(sensor-1);
mydata.soil[sensor] = (val1 + val2) / 2;
digitalWrite(sensor*2, LOW);
digitalWrite(sensor*2+1, LOW);
}