|
|
| Line 898: |
Line 898: |
| | {| 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">untilSonarGreaterThan</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">distance</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">30</span><span class="bigCodePunc">, </span><span class="bigKeywordB">tSensors </span><span class="bigCodeBasic">sensorPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">dgtl8</span><span class="bigCodePunc">)</span> | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">untilSonarGreaterThan</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">distance</span><span class="bigCodePunc">, </span><span class="bigKeywordB">tSensors </span><span class="bigCodeBasic">sensorPort</span><span class="bigCodePunc">)</span> |
| | |- | | |- |
| | | | | | |
| Line 908: |
Line 908: |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) The robot does what it was doing until the sonar sensor reads a value greater than a set distance in centimeters. | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) The robot does what it was doing until the sonar sensor reads a value greater than a set distance in centimeters. |
| | | | |
| − | Range: 0 to 647 (A value of -1 means it cannot detect anything.) | + | Range: 0 to 255 (A value of -1 means it cannot detect anything.) |
| | | | |
| − | Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.) | + | Acceptable Sensors: A/D ports 1 through 16 + interrupt (and your names for them given in Motors and Sensors Setup.) |
| | |- | | |- |
| | |} | | |} |
| Line 921: |
Line 921: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''distance'' | | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''distance'' |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The distance in centimeters that<br />an object must be farther than to count<br />(default: <span class="codeStringsNums">30</span>) | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The distance in centimeters that<br />an object must be farther than to count<br />(default: '''''none''''') |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any whole integer amount from 0 to 647. | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any whole integer amount from 0 to 255. |
| | |- | | |- |
| | | 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">dgtl8</span> [+ <span class="codeStringsNums">dgtl9</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">dgtl1</span> to <span class="codeStringsNums">dgtl11</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="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();
| + | |
| − | untilSonarGreaterThan(); /* wait until the sonar sensor in port dgtl8 (+ dgtl9)
| + | |
| − | detects an object farther than 30cm away (default) */
| + | |
| − | stop();
| + | |
| − | </syntaxhighlight>
| + | |
| | |- | | |- |
| | |} | | |} |
| Line 948: |
Line 935: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> |
| − | forward(63); // go forward at speed 63 | + | forward(63); // go forward at speed 63 |
| − | untilSonarGreaterThan(45, dgtl2); /* wait until the sonar sensor in port dgtl2 (+ dgtl3) | + | untilSonarGreaterThan(45, in2); /* wait until the sonar sensor in port in2 |
| − | detects an object farther than 45cm away */
| + | detects an object farther than 45cm away */ |
| − | stop(); // stop | + | stop(); // stop |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |