Get board info programmatically

Locate the "boards.txt" files in your installation (there are probably several). In these files, locate the lines that contain the text "build. board=" such as:

yun.build.board=AVR_YUN
uno.build.board=AVR_UNO
nano.build.board=AVR_NANO
build.board=AVR_MEGA2560

The text after the '=' sign is what you need. Prepend 'ARDUINO_' to it and test if defined:

#if defined(ARDUINO_AVR_UNO)

Each time we buy some new boards I have a small sketch that I use to effectively give each board a unique 24bit serial number within our collection.

I use:
#include <EEPROM.h>
EEPROM.write

Execute the sketch, then upload a blank sketch.

To get the "serial number" later in our sketches I use:
EEPROM.read

forbrains:
Each time we buy some new boards I have a small sketch that I use to effectively give each board a unique 24bit serial number within our collection.

I use:
#include <EEPROM.h>
EEPROM.write

Execute the sketch, then upload a blank sketch.

To get the "serial number" later in our sketches I use:
EEPROM.read

That's a cool idea.

Why?

I mean, what does a serial number provide? An Uno is an Uno. The only difference between them is the sketch uploaded, so what useful information does a serial number provide?