#define BETA_ARDUINO ARDUINO < 100
I found this peace of code in a sketch around and it look my atention
What is this really?
Without seeing the rest of the code, I guess it's some way to handle both the "beta versions" of the Arduino IDE (i.e. all pre-v1.0 releases of the IDE) to the v1.0 and higher versions of the IDE. There were a few fundamental modifications in the jump from 0.23 to 1.0 to core IDE libraries that made some previous community-made libraries non-functional unless different core libraries were included.
ok but
ARDUINO < 100
means the ARDUINO word is defined inside the arduino core and this way the compiler can determ what version of my IDE I'm using?
I think that the author of the sketch wanted to know if the IDE version you are using is older than Arduino 1.0. If yes, all library .cpp files need #include "WProgram.h"
. If not, all .cpp library files need #include "Arduino.h"
. There should be brackets around "ARDUINO < 100". A better way to accomplish what I just said is:
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
It means if ARDUINO is defined as less than 100, BETA_ARDUINO is defined as 1. Othersie, BETA_ARDUINO is defined as 0.
That was me, I think.
In particular, here: http://www.gammon.com.au/i2c
After IDE 1.0 came out, some of my sketches (particularly the I2C) ones, needed tests in multiple places for things like 'write' instead of 'send', 'read' instead of 'receive', and of course the WProgram.h stuff.
Initially I thought I had to do:
#if ARDUINO && (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
Scattering that through the sketch in multiple places looked messy, so I changed it to:
#define BETA_ARDUINO !(ARDUINO && (ARDUINO >= 100))
In other words, BETA_ARDUINO was true for beta versions of the IDE.
Later on in the sketch:
#if BETA_ARDUINO
Wire.send (x);
#else
Wire.write (x);
#endif
That looked a bit neater than the complicated test every time.
Later on someone pointed out that an undefined symbol was considered to be zero, so the initial define could now be:
#define BETA_ARDUINO ARDUINO < 100
It's the same basic idea.