Need the constrain.h and c (using it for another µcontroller)

Hello!

I'm working on a project with a 8051 controller, and found the Arduino libraries map()-function map() - Arduino Reference, which is great, but I also need the constrain()-function if I am to be sure my values are going to be correct. Can anyone help me with this matter? I can not find the source codes for the function in my Arduino folder :\

Looked at constrain() - Arduino Reference but I need the function prototype.

Have never used an Arduino before, but am looking forward to getting it in the mail soon :wink:

Thank you so much in advance!

The Arduino developers defined constrain() as a macro (rather than a function or a C++ function template). It's in wiring.h in your Arduino installation directory under hardware/arduino/cores/arduino/.

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

Regards,

Dave