|
|
| Line 1,515: |
Line 1,515: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''position'' | | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''position'' |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|A position along the rotation of the sensor<br />that must be reached for it to count<br />(default: <span class="codeStringsNums">2048</span>) | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The function passes if the rotation<br />is greater than this value<br />(default: <span class="codeStringsNums">2048</span>) |
| | | 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 4095. |
| | |- | | |- |
| Line 1,553: |
Line 1,553: |
| | <br /> | | <br /> |
| | | | |
| − | ==== untilSoundLessThan ==== | + | ==== untilPotentiometerLessThan ==== |
| | {| 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">untilSoundLessThan</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">int </span><span class="bigCodeBasic">threshold</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">63</span><span class="bigCodePunc">, </span><span class="bigKeywordB">tSensors </span><span class="bigCodeBasic">sensorPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">S2</span><span class="bigCodePunc">)</span> | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">untilPotentiometerLessThan</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">int </span><span class="bigCodeBasic">position</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">2048</span><span class="bigCodePunc">, </span><span class="bigKeywordB">tSensors </span><span class="bigCodeBasic">sensorPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">in6</span><span class="bigCodePunc">)</span> |
| | |- | | |- |
| | | | | | |
| Line 1,563: |
Line 1,563: |
| | ! style="border-style: solid; border-width: 0px 0px 0px 0px"| | | ! style="border-style: solid; border-width: 0px 0px 0px 0px"| |
| | |- | | |- |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[File:sound_less.png]] | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[File:pot_less_vex.png]] |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) The robot does what it was doing until the sound sensor reads a value less than a set threshold level. | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) The robot does what it was doing until the potentiometer sensor reads a value less than a set position. |
| | | | |
| − | Range: (quiet) 0 to 100 (loud) | + | Range: 0 to 4095 (However due to mechanical stops, you may be limited to the range of 5 to 4090.) |
| | | | |
| − | Acceptable Sensors: sensor ports 1 through 4 (and your names for them given in Motors and Sensors Setup.) | + | Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.) |
| | |- | | |- |
| | |} | | |} |
| Line 1,578: |
Line 1,578: |
| | ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Acceptable Input | | ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Acceptable Input |
| | |- | | |- |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''threshold'' | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''position'' |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The threshold value that <br />a sound must be quieter than to count<br />(default: <span class="codeStringsNums">63</span>) | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The function passes if the rotation<br />is less than this value<br />(default: <span class="codeStringsNums">2048</span>) |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any whole integer amount from 0 to 100. | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any whole integer amount from 0 to 4095. |
| | |- | | |- |
| | | 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">S2</span>) | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the sonar sensor.<br />(default: <span class="codeStringsNums">in6</span>) |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">S1<br />S2<br />S3<br />S4<br /></span>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">in8</span><br />Or their names setup in Motors and Sensors Setup. |
| | |- | | |- |
| | |} | | |} |
| Line 1,594: |
Line 1,594: |
| | | 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(); | | forward(); |
| − | untilSoundLessThan(); /* wait until the sound sensor in port S2
| + | untilPotentiometerLessThan(); /* wait until the potentiometer in port in6 |
| − | detects a sound quieter than 63 (default) */
| + | reads a value less than 2048 (default) */ |
| | stop(); | | stop(); |
| | </syntaxhighlight> | | </syntaxhighlight> |
| Line 1,606: |
Line 1,606: |
| | |- | | |- |
| | | 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 |
| − | untilSoundLessThan(15, S3); /* wait until the sound sensor in port
| + | untilPotentiometerLessThan(40, in4); /* wait until the potentiometer in port in4 |
| − | S3 detects a sound quieter than 15 */
| + | reads a value less than 40 (default) */ |
| − | stop(); // stop | + | stop(); // stop |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |
| The ROBOTC Natural Language Library aims at making learning and using text-based programming languages easier for beginners. The Natural Language Library is filled with commands that are both easy to use and easy to remember. Natural Language commands encompass entire robot behaviors into a single command.
Natural Language can be enabled in ROBOTC by going to the Robot menu, then Platform Type, and then by selecting one of the Natural Language options.
|
| void lineTrackForTime(float trackTime = 5.0, int threshold = 505, tSensors sensorLeft = in1, tSensors sensorCenter = in2, tSensors sensorRight = in3)
|
|
|
|
|
(void) The robot will track a black line on a white surface for a specified time in seconds.
Threshold Range: (dark) 0 to 4095 (light)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| trackTime
|
The amount of time in seconds to track a line. (default: 5.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
|
|
| threshold
|
The threshold to compare colors against. (default: 505)
|
0 to +4095
|
| sensorLeft
|
The sensor port to use for the LEFT line tracking sensor. (default: in1)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorCenter
|
The sensor port to use for the CENTER line tracking sensor. (default: in2)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorRight
|
The sensor port to use for the RIGHT line tracking sensor. (default: in3)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
lineTrackForTime(); /* track a black line for 5.0 seconds,
using a threshold of 505, with the
line tracking sensors in ports:
in1, in2, in3(default) */
stop();
|
|
| Usage and Sample with Parameters
|
lineTrackForTime(7.5, 99, in6, in7, in8); /* track a black line for 7.5 seconds,
using a threshold of 99, with the
line tracking sensors in ports:
in6, in7, in8 */
stop(); // stop
|
|
| void lineTrackForRotations(float rotations = 3.0, int threshold = 505, tSensors sensorLeft = in1, tSensors sensorCenter = in2, tSensors sensorRight = in3)
|
|
|
|
|
(void) The robot will track a black line on a white surface for a specified distance in rotations.
Threshold Range: (dark) 0 to 4095 (light)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| rotations
|
The amount of axle rotations to track a line. (default: 3.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
|
|
| threshold
|
The threshold to compare colors against. (default: 505)
|
0 to +4095
|
| sensorLeft
|
The sensor port to use for the LEFT line tracking sensor. (default: in1)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorCenter
|
The sensor port to use for the CENTER line tracking sensor. (default: in2)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorRight
|
The sensor port to use for the RIGHT line tracking sensor. (default: in3)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
lineTrackForRotations(); /* track a black line for 3.0 rotations,
using a threshold of 505, with the
line tracking sensors in ports:
in1, in2, in3(default) */
stop();
|
|
| Usage and Sample with Parameters
|
lineTrackForRotations(4.75, 99, in6, in7, in8); /* track a black line for 4.75 rotations,
using a threshold of 99, with the
line tracking sensors in ports:
in6, in7, in8 */
stop(); // stop
|
|