Go Down

Topic: Developer Request: Sketch Require Hardware (Read 2 times) previous topic - next topic


Maybe we could have a  way to ensure a certain platform from the sketch?
Or possibly to explicity disallow a platform.

Something like:
Code: [Select]

 Serial echo server for the Arduino Mega

 Uses Serial1

 @require Mega

void setup()

void loop()
 // if we get a valid byte, read analog ins:
 if (Serial1.available() > 0) {
   Serial1.print( Serial1.read() );

Mike Murdock


I think you could do that now by checking the #define'd processor type.  To make it easy, you could define a macro that says, "if processor != desired_type generate compile error"




Feb 16, 2010, 01:29 am Last Edit: Feb 16, 2010, 01:46 pm by AlphaBeta Reason: 1
Oh.. I know I could do it. 8-) Hehe...

But if I where to share that Sketch with a nonprogrammer, I think I would've gotten some questions about all the #ifndef stuff.

Just an idea to keep things simple and self explanatory.

[edit]Oh the shame! ;)
Wayoda's post below made me realize I could not do it, even if I used all the preprocessor directives available.[/edit]



I think you could do that now by checking the #define'd processor type.  

No you can't. For instance the Duemilanove and the Nano board both have a 328p processor, but  only the Nano board supports the analog inputs A6 and A7.


Mike Murdock


Excellent point.  Maybe the request could be to #define a board type, if the IDE doesn't already do this.



Go Up