|
|
| Line 949: |
Line 949: |
| | {| 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">untilSonarLessThan</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">untilSonarLessThan</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 959: |
Line 959: |
| | | 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 less 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 less 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 972: |
Line 972: |
| | |- | | |- |
| | | 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();
| + | |
| − | untilSonarLessThan(); /* wait until the sonar sensor in port dgtl8 (+ dgtl 9)
| + | |
| − | detects an object closer than 30cm away (default) */
| + | |
| − | stop();
| + | |
| − | </syntaxhighlight>
| + | |
| | |- | | |- |
| | |} | | |} |
| Line 999: |
Line 986: |
| | |- | | |- |
| | | 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 |
| − | untilSonarLessThan(45, dgtl2); /* wait until the sonar sensor in port dgtl2 (+ dgtl3) | + | untilSonarLessThan(45, in2); /* wait until the sonar sensor in port in2 |
| − | detects an object closer than 45cm away */
| + | detects an object closer than 45cm away */ |
| − | stop(); // stop | + | stop(); // stop |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |