Last active
December 16, 2017 11:23
-
-
Save smetronic/bbfa499db4b7098950fd31d7aa7aeb66 to your computer and use it in GitHub Desktop.
ATMega 328p: Unique Id/Serial Number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/boot.h> | |
void print_val(char *msg, uint8_t val) | |
{ | |
Serial.print(msg); | |
Serial.println(val, HEX); | |
} | |
void setup(void) | |
{ | |
Serial.begin(9600); | |
while (!Serial) ; | |
#define SIGRD 5 | |
#if defined(SIGRD) || defined(RSIG) | |
Serial.print("Signature : "); | |
for (uint8_t i = 0; i < 5; i += 2) { | |
Serial.print(" 0x"); | |
Serial.print(boot_signature_byte_get(i), HEX); | |
} | |
Serial.println(); | |
Serial.print("Serial Number : "); | |
for (uint8_t i = 14; i < 24; i += 1) { | |
Serial.print(" 0x"); | |
Serial.print(boot_signature_byte_get(i), HEX); | |
} | |
Serial.println(); | |
#endif | |
} | |
void loop() | |
{ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment