Stokes’ ProjBlog

A journal documenting innumerable, mostly terminally in-progress undertakings. Nerdiness abounds.

 

Random idea: unique IDs on the Arduino September 23, 2009

Filed under: Miscelaneous Projects,New project! — Stokes @ 4:08 pm

I was thinking about ways to create multiplayer games/toys using the Arduino platform and realized a key difficulty: telling different Arduinos apart when there are more than two. Optimally, the system should not depend on one Arduino being the ‘boss’ and should be as simple as possible for the programmer. I think I have a solution.

This is the idea: modify the pre-compiler (or, more specifically, the IDE code that calls the precompiler) to automatically include a #define statement, defining MY_UNIQUE_ID as the last sixteen bits of the build time in milliseconds. The chances of two Arduino builds being done in the same thousandth of a second are extraordinarily low, effectively making the ID unique for all practical reasons. In the code, all the programmer needs to do is use MY_UNIQUE_ID as a variable.

I’ll have to take a look at the Arduino IDE source.

Update (9/24): A couple of people have commented on this on Facebook (where this appears via RSS), suggesting some dynamic, real-time solutions. These are good ideas, but the situation I was imagining isn’t one in which all the points would have access to each other simultaneously; instead, temporary connections are being made between units, probably by physical contact.

 

Leave a Reply

You must be logged in to post a comment.