Determine Which Arduino µC Your Code is On?

Need to determine which Arduino µC processor (ATmega168, 328, 1280 or 2560) your code is running on?

Simply access the signature bytes.

Example:

#include <avr/signature.h>

void setup(void) {
  Serial.begin(9600);
  Serial.println(SIGNATURE_0, HEX);
  Serial.println(SIGNATURE_1, HEX);
  Serial.println(SIGNATURE_2, HEX);
}

void loop(void) {
}

Which produces the following output on an Arduino Mega (ATMega1280):
1E
97
3

Signature Bytes:

ATmega168 0x1e 0x94 0x06
ATmega328 0x1e 0x95 0x0f
ATmega1280 0x1e 0x97 0x03
ATmega2560 0x1e 0x98 0x01

The first byte (0x1e) indicates ATMEL manufactured the chip.
The second byte indicates the amount of flash memory on the chip (0x94 = 16K, 0x95 = 32K, etc.).
The third byte indicates the µC processor.

Advertisements

About Jim Eli

µC experimenter
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s