# Identifying your Arduino board from code

DevFeed: [Identifying your Arduino board from code](<https://devfeed.tech/articles/identifying-your-arduino-board-from-code-20705.md>)

Original publisher: [Read original article](<https://docs.microsoft.com/archive/blogs/abhinaba/identifying-your-arduino-board-from-code>)

Author: Abhinaba Basu \[MSFT\]

Published: 2016-02-21T16:18:49Z

Content type: article

Language: en

Sources: [Abhinaba Basu](<https://devfeed.tech/sources/abhinaba-basu.md>)

Topics: [Arduino](<https://devfeed.tech/topics/arduino.md>)

Tags: [arduino](<https://devfeed.tech/tags/arduino.md>), [arduino-ide](<https://devfeed.tech/tags/arduino-ide.md>), [avr](<https://devfeed.tech/tags/avr.md>), [board](<https://devfeed.tech/tags/board.md>), [code](<https://devfeed.tech/tags/code.md>), [esp8266](<https://devfeed.tech/tags/esp8266.md>), [github](<https://devfeed.tech/tags/github.md>), [hardware](<https://devfeed.tech/tags/hardware.md>), [iot](<https://devfeed.tech/tags/iot.md>), [powershell](<https://devfeed.tech/tags/powershell.md>), [serial](<https://devfeed.tech/tags/serial.md>)

## AI overview

The Arduino IDE's selected board can drive board-specific code through compile-time defines. The excerpt says each board's `boards.txt` entry has a `.board` value; prefixing it with `ARDUINO_` yields a define such as `ARDUINO_AVR_MEGA2560`. A PowerShell routine recursively searches for `boards.txt`, pairs board names with `.board` values, and prints those defines. The author uses them with `#ifdef` to select `Serial1` for a Mega 2560 and `Serial` for a Nano. The examples and file location are from Arduino IDE 1.6.5.

## Source excerpt

For my IoT project I needed to write code slightly differently for specific Arduino boards. E.g....