New answers tagged

3

Separate pin definitions Clearer and easier to maintain. //#define SLAVEPINS 8, 9 //SoftwareSerial serial(SLAVEPINS); // RX, TX #define SLAVEPINS_RX 8 #define SLAVEPINS_TX 9 SoftwareSerial serial(SLAVEPINS_RX, SLAVEPINS_TX); Code guards #ifndef _SLAVE_H #define _SLAVE_H 1 #define SLAVEPINS 8, 9 #define SLAVEEVENT 200 .... #endif Also see #pragma ...


3

Use a common protocol file Any common constants, such as 9600 SYN, ACK, etc. strings should be #defined in one place, in this case a .h file accessible to both Arduino projects. Indentation One-space indentation is essentially never used. Typically four is used instead. Globals In the master code, every single one of those globals should be moved to ...


Top 50 recent answers are included