Last active
April 15, 2016 01:18
-
-
Save mpflaga/c1f957f4f5146b990c28daa8d82fb16e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <EasyTransfer.h> | |
#define LENGTH_OF_ARRAY(x)((sizeof(x) / sizeof(x[0]))) | |
//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 arraydata[5]; | |
}; | |
//give a name to the group of data | |
SEND_DATA_STRUCTURE mydata; | |
void setup() { | |
Serial1.begin(57600); | |
//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), &Serial1); | |
} | |
void loop() { | |
//this is how you access the variables. [name of the group].[variable name] | |
int arraydata[] = {0x31,0x32,0x33,0x34,0x35}; | |
memcpy(mydata.arraydata, arraydata, sizeof(arraydata)); | |
//send the data | |
ET.sendData(); | |
// Serial.println(mydata.arraydata[2], HEX); | |
for (uint8_t channel = 0; channel < LENGTH_OF_ARRAY(arraydata); channel++) { | |
Serial.print("arraydata["); | |
Serial.print(channel); | |
Serial.print("]="); | |
Serial.print(arraydata[channel], HEX); | |
Serial.print(", mydata.arraydata["); | |
Serial.print(channel); | |
Serial.print("]="); | |
Serial.println(mydata.arraydata[channel], HEX); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment