S
S
smart_alex2018-03-13 09:09:25
Arduino
smart_alex, 2018-03-13 09:09:25

How to switch compilation of libraries in Arduino?

Simple sketch

#include <SPI.h>

#define MODE_LIB

#include <Ethernet.h>
//#include <Ethernet2.h>

byte mac[] = {0x00, 0x2A, 0xF5, 0x12, 0x67, 0x5A};
byte ip[]  = {192, 168, 1, 55};

void setup() {
  Ethernet.begin(mac, ip);
}

void loop() {
}

You need to compile the sketch with either the Ethernet.h library or the Ethernet2.h library. Now this can only be done by manually commenting out either the first or the second library.
The task is to connect the first or second library not manually by commenting, but depending on the definition of MODE_LIB. That is, if MODE_LIB is defined, then the Ethernet.h library is connected and compiled, if MODE_LIB is not defined, then the Ethernet2.h library is connected and compiled.
A warning. The task is not as simple as it seems, and please, before writing answers, check their real performance for yourself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
evgeniy_lm, 2018-03-13
@evgeniy_lm

Something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question