|
|
| Line 1,161: |
Line 1,161: |
| | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" |
| | |- | | |- |
| − | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">untilLight</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">int </span><span class="bigCodeBasic">threshold</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">505</span><span class="bigCodePunc">, </span><span class="bigKeywordB">tSensors </span><span class="bigCodeBasic">sensorPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">in2</span><span class="bigCodePunc">)</span> | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">untilLight</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">int </span><span class="bigCodeBasic">threshold</span><span class="bigCodePunc">, </span><span class="bigKeywordB">tSensors </span><span class="bigCodeBasic">sensorPort</span><span class="bigCodePunc">)</span> |
| | |- | | |- |
| | | | | | |
| Line 1,171: |
Line 1,171: |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) The robot does what it was doing until the light sensor reads a value lighter than the threshold. | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) The robot does what it was doing until the light sensor reads a value lighter than the threshold. |
| | | | |
| − | Range: (light) 0 to 4095 (dark) | + | Range: (light) 0 to 1023 (dark) |
| | | | |
| − | Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.) | + | Acceptable Sensors: A/D ports 1 through 16 (and your names for them given in Motors and Sensors Setup.) |
| | |- | | |- |
| | |} | | |} |
| Line 1,184: |
Line 1,184: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''threshold'' | | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''threshold'' |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The threshold value that <br />an object must be lighter than to count<br />(default: <span class="codeStringsNums">505</span>) | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The threshold value that <br />an object must be lighter than to count<br />(default: '''''none''''') |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any whole integer amount from 0 to 4095. | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any whole integer amount from 0 to 1023. |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the sonar sensor.<br />(default: <span class="codeStringsNums">in2</span>) | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the sonar sensor.<br />(default: '''''none''''') |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in16</span><br />Or their names setup in Motors and Sensors Setup. |
| | |- | | |- |
| | |} | | |} |
| | |- | | |- |
| | | | | | |
| − | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 0px; border-style: solid; border-color: #000;" cellpadding="5%"
| + | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 0px; border-style: solid; border-color: #000;" cellpadding="5%" |
| − | ! style="border-style: solid; border-width: 0px 0px 0px 0px"|Default Usage and Sample
| + | |
| − | |-
| + | |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC">
| + | |
| − | forward();
| + | |
| − | untilLight(); /* wait until the light sensor in port in2
| + | |
| − | detects an object lighter than 505 (default) */
| + | |
| − | stop();
| + | |
| − | </syntaxhighlight>
| + | |
| − | |-
| + | |
| − | |}
| + | |
| − | |-
| + | |
| − | |
| + | |
| − | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 0px; border-style: solid; border-color: #000;" cellpadding="5%"
| + | |
| | ! style="border-style: solid; border-width: 0px 0px 0px 0px"|Usage and Sample with Parameters | | ! style="border-style: solid; border-width: 0px 0px 0px 0px"|Usage and Sample with Parameters |
| | |- | | |- |
| void untilRotations(float rotations = 1.0, tSensors sensorPort = dgtl1)
|
|
|
|
|
(void) The robot does what it was doing until the motor encoder rotations match the desired value.
Range: -262,144.00 to +262,144.00
Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| rotations
|
The amount of axle rotations to reach. (default: 1.0)
|
Any floating point amount:
|
|
|
| 0.####
|
-2,048.0000 to +2,048.0000
|
| 0.###
|
-32,768.000 to +32,768.000
|
| 0.##
|
-262,144.00 to +262,144.00
|
| 0.#
|
-2,097,200.0 to +2,097,200.0
|
|
| sensorPort
|
The quadrature encoder to use. (default: dgtl1 [+ dgtl1])
|
dgtl1 to dgtl11 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilRotations(); /* wait until the quadrature encoder in port
dgtl1 (+ dgtl2) counts 1.0 rotations (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // move forward at speed 63
untilRotations(3, dgtl3); /* wait until the quadrature encoder in port
dgtl3 (+ dgtl4)counts 3 rotations */
stop(); // stop
|
|
| void untilEncoderCounts(long distance = 360, tSensors sensorPort = dgtl1)
|
|
|
|
|
(void) The robot does what it was doing until the motor encoder counts match the desired value.
Range: -2,147,483,648 to +2,147,483,647
Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| distance
|
The amount of encoder counts to reach. (default: 360)
|
Any whole integer amount from -2,147,483,648 to +2,147,483,647
|
| sensorPort
|
The quadrature encoder to use. (default: dgtl1 [+ dgtl1])
|
dgtl1 to dgtl11 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilEncoderCounts(); /* wait until the quadrature encoder in port
dgtl1 (+ dgtl2) counts 360 encoder counts (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // move forward at speed 63
untilEncoderCounts(990, dgtl3); /* wait until the quadrature encoder in port
dgtl3 (+ dgtl4)counts 990 encoder counts */
stop(); // stop
|
|