Author Topic: Identify board at compile time  (Read 2640 times)

pedro.albuquerque

  • NewMember
  • *
  • Posts: 19
  • Country: pt
Identify board at compile time
« on: November 18, 2017, 11:53:37 AM »
I have seen some code that allow to determine the board being used/select at compile time.
code like

Code: [Select]
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

When using Atom with platformIO the value that is representing Moteino is

Code: [Select]
#if defined( ARDUINO_AVR_MOTEINO) || defined(ARDUINO_AVR_MOTEINOMEGA) || defined(ARDUINO_AVR_NANO)

and is working fine, but....  when using Arduino IDE, this value are not defined, nor the ones above "__AVR_ATmega1280__"

What would be the right value to test for Moteino and MoteinoMega ?

thank you for any help you can provide.

pedro.albuquerque

  • NewMember
  • *
  • Posts: 19
  • Country: pt
Re: Identify board at compile time
« Reply #1 on: November 18, 2017, 12:06:07 PM »
meanwhile managed to find a piece of code with this MACRO define.

Maybe someone else have the doubt  :D

Code: [Select]
#if defined(__AVR_ATmega1284P__)
    Serial.println("MOTEINOMEGA");
#endif
#if defined(__AVR_ATmega328P__)
    Serial.println("MOTEINO");
  #endif




Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Identify board at compile time
« Reply #2 on: November 18, 2017, 10:07:16 PM »
Yes that works and I use it in my own sketches.