Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the constant ARDUINO for? it used to be 22 but is now 100

I am using thermocouples and downloaded the MAX6675 library. I wondered what the value of the ARDUINO constant in the following lines is for.

#if ARDUINO >= 100
  lcd.write((byte)0);
#else
  lcd.print(0, BYTE);
#endif
  lcd.print("C ");
  lcd.print(thermocouple.readFahrenheit());
#if ARDUINO >= 100
  lcd.write((byte)0);
#else
  lcd.print(0, BYTE);
#endif
  lcd.print('F');

I have searched for the answer but have turned up very little info. I can print out the value with the following line, but I still can't find out what it means.

Serial.println(ARDUINO);

like image 585
Eugene Avatar asked Dec 19 '22 03:12

Eugene


1 Answers

The ARDUINO constant gives the version of the Arduino environment being used.

For example, 22 was for the old Arduino 22 IDE and 100 is for version 1.0 of the Arduino environment. The value of the ARDUINO constant in the latest Arduino release (1.6.5) appears to be 10605.

There were some significant changes in the Arduino APIs between the old versions (e.g. 22) and the 1.0 release. The value of ARDUINO can be used to conditionally compile different code for different versions of the API.

In your example it appears that in the version 1.0+ environment you need to use lcd.write() but in the old environments you had to use lcd.print. Testing the value of ARDUINO allows the same code to work in both environments.

like image 58
mttrb Avatar answered Dec 28 '22 09:12

mttrb