[Math]
描述
Constrains a number to be within a range.
語法
constrain(x, a, b)
參數
X: the number to constrain, all data typesa: the lower end of the range, all data typesb: the upper end of the range, all data types
回傳
X: if X is between a 以及 ba: if X is less than ab: if X is greater than b
範例程式碼
sensVal = constrain(sensVal, 10, 150); // limits range of sensor values to between 10 and 150
參考
語法參考主頁面
86Duino 參考的文本是根據 知識共享署名-相同方式分享 3.0 許可證,部分文本是從 Arduino 參考 修改的。 參考中的代碼示例已發佈到公共領域。



