Difference between revisions of "ARDUINO MEGA Functions Sensors"

From ROBOTC API Guide
Jump to: navigation, search
(SensorType)
(SensorType)
Line 50: Line 50:
 
|-
 
|-
 
| 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 manually specify what type of sensor is connected to a specific pin. 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 manually specify what type of sensor is connected to a specific pin. Most users should not have to use this functionality and should use the Motors and Sensor Setup instead.
 +
  
 
{| class="parameterTable" cellpadding="5%" width="100%"
 
{| class="parameterTable" cellpadding="5%" width="100%"
Line 61: Line 62:
 
   |-
 
   |-
 
   |}
 
   |}
 +
  
 
   {|
 
   {|

Revision as of 15:27, 10 May 2012

ARDUINOFunctions and Variables → ARDUINO MEGA Functions Sensors
Color Key
Function:
Variable:


Information

The Arduino MEGA has 16 analog sensor ports and 53 digital sensor ports.

Analog: No Sensor - No Sensor Attached. Pin is disabled.

Potentiometer - Standard Analog Input (0-1023), no modification to raw value.

Light Sensor - Standard Analog Input (0-1023), no modification to raw value.

Line Follower - Standard Analog Input (0-1023), no modification to raw value.

Gyro Sensor - Support for VEX Gyro Sensor. See documentation here.

Accelerometer - Support for VEX Accelerometer. See documentation here.

Digital In - Use an analog pin as a digital input (not currently supported)

Digital Out - Use an analog pin as a digital output (not currently supported)

Digital:

No Sensor - No Sensor Attached. Pin is disabled.

Touch - Digital Input for touch sensors. (reversed from "Digital In" command)

Quadrature Encoder (Two Pins) - Support for VEX Quadrature Encoder. See documentation here.

LED to Vcc - Pin configured as digital output with reversed logic (for LEDs) (0 = LED on, 1 = LED off)

Digital In - Pin configured as digital input with internal "Pull-Up" resistor enabled.

Digital Out - Pin configured as digital output.

Digital High Inpedance - Pin configured as digital input without the "Pull-Up" resistor enabled.

Sonar [Ping] - Support for Parallax Ping Sonar Sensor (returns distance in cm, mm, inches, raw)

Sonar [SRP-04] (Two Pins) - Support for VEX Robotics Sonar Sensor (returns distance in cm, mm, inches, raw)

SensorType

TSensorTypes SensorType[tSensors sensor]
(TSensorTypes) The SensorType array is used to manually specify what type of sensor is connected to a specific pin. Most users should not have to use this functionality and should use the Motors and Sensor Setup instead.


Parameter Explanation Data Type
sensor A sensor port or name tSensors


SensorType[dgtl3] = sensorTouch;  // set digital pin #3 to be of type sensorTouch


SensorValue

word SensorValue[tSensors sensor]
(word) This array value will return and modify the value of the sensor. When a pin is set as an "input" the SensorValue array command will return the value from the sensor attached to that pin. When a pin is set as an "output", the SensorValue array can be written to set the output value of the pin (typically Digital Outs will be set to 0 for Low and 1 for High).


Parameter Explanation Data Type
sensor A sensor port or name tSensors


while(SensorValue[dgtl6] == 0) //Loop while digital pin #6 is low (set to zero)
{
   motor[motor_2] = 63;   // Motor pin #2 is run at half (63) power forward
   motor[motor_3]  = 63;   // Motor pin #3 is run at half (63) power forward
}