File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,24 @@ The code limits the sensor values to between 10 to 150.
60
60
sensVal = constrain(sensVal, 10, 150); // limits range of sensor values to between 10 and 150
61
61
----
62
62
63
+ [float]
64
+ === Notes and Warnings
65
+ Because of the way the `constrain()` function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results.
66
+
67
+ This code will yield incorrect results:
68
+ [source,arduino]
69
+ ----
70
+ int constrainedInput = constrain(Serial.parseInt(), minimumValue, maximumValue); // avoid this
71
+ ----
72
+
73
+ Use this instead:
74
+ [source,arduino]
75
+ ----
76
+ int input = Serial.parseInt(); // keep other operations outside the constrain function
77
+ int constrainedInput = constrain(input, minimumValue, maximumValue);
78
+ ----
79
+ [%hardbreaks]
80
+
63
81
--
64
82
// HOW TO USE SECTION ENDS
65
83
Original file line number Diff line number Diff line change @@ -38,6 +38,32 @@ The square of the number. (double)
38
38
// OVERVIEW SECTION ENDS
39
39
40
40
41
+ // HOW TO USE SECTION STARTS
42
+ [#howtouse]
43
+ --
44
+
45
+ [float]
46
+ === Notes and Warnings
47
+ Because of the way the `sq()` function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results.
48
+
49
+ This code will yield incorrect results:
50
+ [source,arduino]
51
+ ----
52
+ int inputSquared = sq(Serial.parseInt()); // avoid this
53
+ ----
54
+
55
+ Use this instead:
56
+ [source,arduino]
57
+ ----
58
+ int input = Serial.parseInt(); // keep other operations outside the sq function
59
+ int inputSquared = sq(input);
60
+ ----
61
+ [%hardbreaks]
62
+
63
+ --
64
+ // HOW TO USE SECTION ENDS
65
+
66
+
41
67
// SEE ALSO SECTION
42
68
[#see_also]
43
69
--
You can’t perform that action at this time.
0 commit comments