Difference between revisions of "ARDUINO 328 Functions Sensors"
From ROBOTC API Guide
m (moved ARDUINO Functions Sensors to ARDUINO 328 Functions Sensors) |
|||
Line 34: | Line 34: | ||
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class=" | + | | class="variableType"| <span class="bigKeywordBI">const word </span><span class="bigKeywordB">SensorBoolean</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">tSensors sensor</span><span class="bigCodePunc">]</span> |
|- | |- | ||
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_word|word]]) This returns a true or false reading from the sensor. (Mostly used by Touch sensors). | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_word|word]]) This returns a true or false reading from the sensor. (Mostly used by Touch sensors). | ||
Line 69: | Line 69: | ||
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class=" | + | | class="variableType"| <span class="bigKeywordBI">word </span><span class="bigKeywordB">SensorRaw</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">tSensors sensor</span><span class="bigCodePunc">]</span> |
|- | |- | ||
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_word|word]]) This array value will return the "raw" (un-normalized) value of a sensor. Usually this is the raw A-D converted value, which is an analog value between 0 to 1023. | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_word|word]]) This array value will return the "raw" (un-normalized) value of a sensor. Usually this is the raw A-D converted value, which is an analog value between 0 to 1023. | ||
Line 104: | Line 104: | ||
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class=" | + | | class="variableType"| <span class="bigKeywordB">TSensorTypes </span><span class="bigKeywordB">SensorType</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">tSensors sensor</span><span class="bigCodePunc">]</span> |
|- | |- | ||
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_TSensorTypes|TSensorTypes]]) The SensorType array is used to specify what type of sensor is connected to a certain port. Most users should not have to use this functionality and should use the Motors and Sensor Setup instead. | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_TSensorTypes|TSensorTypes]]) The SensorType array is used to specify what type of sensor is connected to a certain port. Most users should not have to use this functionality and should use the Motors and Sensor Setup instead. | ||
Line 136: | Line 136: | ||
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
− | | class=" | + | | class="variableType"| <span class="bigKeywordBI">word </span><span class="bigKeywordB">SensorValue</span><span class="bigCodePunc">[</span><span class="bigCodeBasic">tSensors sensor</span><span class="bigCodePunc">]</span> |
|- | |- | ||
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_word|word]]) This array value returns the value of the sensor in a normalized fashion. Rather than returning a raw value of 0 to 1023, ROBOTC will interpret the data from the "SensorType" and return a more accurate representation of the sensor's data. An example of this is the Light Sensor, which will return a percentage value from 0 to 100. | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_word|word]]) This array value returns the value of the sensor in a normalized fashion. Rather than returning a raw value of 0 to 1023, ROBOTC will interpret the data from the "SensorType" and return a more accurate representation of the sensor's data. An example of this is the Light Sensor, which will return a percentage value from 0 to 100. |
Revision as of 21:27, 10 May 2012
Functions and Variables → Sensors
For more examples and explanations, head over to CORTEX Sensors Overview page! For information and examples on using I2C sensors, head over to CORTEX I2C Digital Sensors page! |
|
Information
The VEX 2.0 Cortex is equipped with 20 sensor ports. There are 8 Analog Sensor Ports and 12 Digital Sensor Ports. Note that unlike the VEX - PIC microcontroller, all Analog sensors must be in Analog ports, while all Digital sensors must be in Digital ports.
There are a variety of functions and variables used for configuring these ports and accessing their values. Configuring sensors can be complicated. ROBOTC has a built-in wizard that can be used to configure the VEX 2.0 Cortex sensors. The wizard contains a number of PC windows that allow you to set the following fields for the sensor:
|
SensorBoolean
const word SensorBoolean[tSensors sensor] | |||||||
(word) This returns a true or false reading from the sensor. (Mostly used by Touch sensors).
|
SensorRaw
word SensorRaw[tSensors sensor] | |||||||
(word) This array value will return the "raw" (un-normalized) value of a sensor. Usually this is the raw A-D converted value, which is an analog value between 0 to 1023.
|
SensorType
TSensorTypes SensorType[tSensors sensor] | |||||||
(TSensorTypes) The SensorType array is used to specify what type of sensor is connected to a certain port. Most users should not have to use this functionality and should use the Motors and Sensor Setup instead.
|
SensorValue
word SensorValue[tSensors sensor] | |||||||
(word) This array value returns the value of the sensor in a normalized fashion. Rather than returning a raw value of 0 to 1023, ROBOTC will interpret the data from the "SensorType" and return a more accurate representation of the sensor's data. An example of this is the Light Sensor, which will return a percentage value from 0 to 100.
|