Sensing#
Brain Sensing#
Reset Timer#
The Reset Timer block is used to reset the IQ Brain’s timer.
The Brain’s timer begins at the beginning of each project. The reset timer block is used to reset the timer back to 0 seconds.
In this example, the Brain will print the current time after waiting 2 seconds before resetting its timer.
Timer Value#
The Timer Value block is used to report the value of the IQ Brain’s timer in seconds.
The timer starts at 0 seconds when the program starts, and reports the timer’s value as a decimal value.
In this example, the Brain will print the current time after waiting 2 seconds before resetting its timer.
Cursor Column#
The Cursor Column block is used to report the column number of the IQ Brain’s screen cursor location.
The Cursor Column block will report a value from 1-80 and will start on column 1 at the start of a project.
In this example, the Brain will print the number of the column the cursor is currently on.
Cursor Row#
The Cursor Row block is used to report the row number of the IQ Brain’s screen cursor location.
The Cursor Row block will report a value from 1-9 and will start on row 1 at the start of a project.
In this example, the Brain will print the number of the row the cursor is currently on.
Battery Capacity#
The Battery Capacity block is used to report the charge level of the IQ Brain’s battery.
The Battery Capacity block reports a range from 0% to 100%.
In this example, the Brain will print its current battery charge on the Brain’s screen.
Controller Sensing#
Controller Pressed#
The Controller Pressed block is used to report if a button on the IQ Controller is pressed.
The Controller Pressed block reports True
when the selected Controller button is pressed.
The Controller Pressed block reports False
when the selected Controller button is not pressed.
Choose which Controller button to use.
In this example, the Brain will print a message on its screen the first time the R Up button on the controller is pressed.
Position of Controller#
The Position of Controller block is used to report the position of a joystick on the IQ Controller along an axis.
The Position of Controller block reports a range from -100 to 100.
The Position of Controller block reports 0 when the joystick axis is centered.
Choose the joystick’s axis.
In this example, the Brain will print the C axis of the IQ Controller’s joysticks.
Controller Enable/Disable#
The Controller Enable/Disable block is used to enable or disable Controller configured actions from the Devices menu.
Choose to either enable or disable the configured Controller actions. By default, the Controller is Enabled in every project.
In this example, the Controller will be disabled at the start of the project and be re-enabled after the drivetrain has moved forward for 6 inches.
Motor Sensing#
Motor is Done?#
The Motor is Done? block is used to report if the selected IQ Smart Motor or Motor Group has completed its movement.
The Motor is Done? block reports True
when the selected Motor or Motor Group has completed its movement.
The Motor is Done? block reports False
when the selected Motor or Motor Group is still moving.
Choose which Motor or Motor Group to use.
Motor is Spinning?#
The Motor is Spinning? block is used to report if the selected IQ Smart Motor or Motor Group is currently moving.
The Motor is Spinning? block reports True
when the selected Motor or Motor Group is moving.
The Motor is Spinning? block reports False
when the selected Motor or Motor Group is not moving.
Choose which Motor or Motor Group to use.
Position of Motor#
The Position of Motor block is used to report the distance an IQ Smart Motor or the first motor of a Motor Group has traveled.
Choose which Motor or Motor Group to use.
Choose the units to report in, degrees or turns.
In this example, the Motor will spin forward for 1 second before its current position is printed on the Brain’s screen.
Velocity of Motor#
The Velocity of Motor block is used to report the current velocity of an IQ Smart Motor or the first motor of a Motor Group.
The Velocity of Motor block reports a range from -100% to 100% or -600rpm to 600rpm.
Choose which Motor or Motor Group to use.
Choose the units to report in, percent (%) or rpm.
In this example, the Motor will spin forward for 1 second before its current velocity is printed on the Brain’s screen.
Current of Motor#
The Current of Motor block is used to report the amount of current a IQ Smart Motor or Motor Group is drawing in amperes (amps).
Choose which Motor or Motor Group to use.
In this example, the Motor will spin forward for 1 second before its current is printed on the Brain’s screen.
Drivetrain Sensing#
Drive is Done?#
The Drive is Done? block is used to report if the Drivetrain has completed its movement.
The Drive is Done? block reports True
when the Drivetrain’s motors have completed their movement.
The Drive is Done? block reports False
when the Drivetrain’s motors are still moving.
Drive is Moving?#
The Drive is Moving? block is used to report if the Drivetrain is currently moving.
The Drive is Moving? block reports True
when the Drivetrain’s motors are moving.
The Drive is Moving? block reports False
when the Drivetrain’s motors are not moving.
Drive Heading#
The Drive Heading block is used to report the direction that the Drivetrain is facing by using the Inertial sensor’s current angular position.
The Drive Heading block reports a range from 0.0 to 359.99 degrees.
In this example, the Drivetrain will turn to the right for 1 second before its current heading is printed on the Brain’s screen.
Drive Rotation#
The Drive Rotation block is used to report the Drivetrain’s angle of rotation.
A clockwise direction is reported as a positive value, and a counterclockwise value is reported as a negative value.
In this example, the Drivetrain will turn to the left for 1 second before its current rotation is printed on the Brain’s screen.
Drive Velocity#
The Drive Velocity block is used to report the current velocity of the Drivetrain.
The Drive Velocity block reports a range from -100% to 100% or -600rpm to 600rpm.
Choose the units to report in, percent (%) or rpm.
In this example, the Drivetrain will drive forward for 1 second before its current velocity is printed on the Brain’s screen.
Drive Current#
The Drive Current block is used to report the amount of current (power) that the Drivetrain is currently using.
In this example, the Drivetrain will drive forward for 1 second before its current is printed on the Brain’s screen.
Bumper Sensing#
Bumper Pressed#
The Bumper Pressed block is used to report if the Bumper Switch is pressed.
The Bumper Pressed block reports True
when the selected Bumper Switch is pressed.
The Bumper Pressed block reports False
when the selected Bumper Switch is not pressed.
Choose which Bumper Switch to use.
In this example, the Brain will print a message on its screen the first time the Bumper Switch is pressed.
Touch LED Sensing#
Touch LED Pressed#
The Touch LED Pressed block is used to report if the Limit Switch is pressed.
The Touch LED Pressed block reports True
when the selected Touch LED is pressed.
The Touch LED Pressed block reports False
when the selected Touch LED is not pressed.
Choose which Limit Switch to use.
In this example, the Brain will print a message on its screen the first time the Touch LED is pressed.
Gyro Sensing#
Calibrate Gyro#
The Calibrate Gyro block is used to calibrate the VEX IQ Gyro Sensor is used to reduce the amount drift generated by Gyro Sensor.
The Gyro Sensor must remain still during the calibration process.
Choose which Gyro Sensor to use.
Choose how long to calibrate the Gyro Sensor for:
2 seconds
4 seconds
8 seconds
In this example, the Brain’s Gyro Sensor will calibrate for 2 seconds before printing the current heading of the Gyro Sensor.
Set Heading#
The Set Heading block is used to set the Gyro Sensor current heading position to the specified value.
The Set Heading block accepts a range of 0.0 to 359.99 degrees.
Choose which Gyro Sensor to use.
In this example, the Brain’s Gyro sensor will print its starting heading, set its heading to 90 degrees, and then print the new heading.
Set Rotation#
The Set Rotation block is used to set the Gyro Sensor current rotation position to the specified value.
The Set Rotation block accepts any positive or negative decimal or integer number.
Choose which Gyro Sensor to use.
In this example, the Brain’s Gyro Sensor will print its starting rotation, set its rotation to -100 degrees, and then print the new rotation.
Angle of Heading#
The Angle of Heading block is used to report the VEX IQ Gyro Sensor’s current heading in degrees.
The Angle of Heading block reports a range from 0.0 to 359.99 degrees.
Choose which Gyro Sensor to use.
In this example, the Brain’s Gyro sensor will print its starting heading, set its heading to 90 degrees, and then print the new heading.
Angle of Rotation#
The Angle of Rotation block is used to report the VEX IQ Gyro Sensor’s current rotation in degrees.
A clockwise direction is reported as a positive value, and a counterclockwise value is reported as a negative value.
Choose which Gyro Sensor to use.
In this example, the Brain’s Inertial sensor will print its starting rotation, set its rotation to -100 degrees, and then print the new heading.
Rate of Gyro#
The Rate of Gyro block is used to report the VEX IQ Gyro Sensor’s rate of angular velocity.
The Rate of Gyro block reports a range between 0 to 249.99 dps.
Choose which Gyro Sensor to use.
In this example, the current Gyro Sensor’s rate will be printed to the Brain’s screen.
Color Sensing#
Color Sensor Found an Object#
The Color Sensor Found an Object block is used to report if the VEX IQ Color Sensor detects an object.
The Color Sensor Found an Object block reports True
when the Color Sensor detects an object or surface close to the front of the sensor.
The Color Sensor Found an Object block reports False
when the Color Sensor does not detect an object or surface close to the front of the sensor.
Choose which Color Sensor to use.
In this example, when the Color Sensor detects an object, it will print a message to the Brain.
Color Sensor Detects Color#
The Color Sensor Detects Color block is used to report if the VEX IQ Color Sensor detects a specific color.
The Color Sensor Detects Color block reports True
when the Color Sensor detects the selected color.
The Color Sensor Detects Color block reports False
when the Color Sensor detects a different color than the one selected.
Choose which Color Sensor to use.
Choose which color to detect.
In this example, when the Color Sensor detects the color green, it will print the detected color to the Brain.
Color Sensor Color Name#
The Color Sensor Color Name block is used to report the name of the color detected by the VEX IQ Color Sensor.
Choose which Color Sensor to use.
In this example, when the Color Sensor detects the color green, it will print the detected color to the Brain.
Color Sensor Brightness#
The Color Sensor Brightness block is used to report the amount of light detected by the VEX IQ Color Sensor.
Choose which Color Sensor to use.
In this example, the Color Sensor will print the current brightness to the Brain.
Color Sensor Hue#
The Color Sensor Hue block is used to report the hue of the color detected by the VEX IQ Color Sensor.
The Color Sensor Hue block reports a range from 0 to 360.
Choose which Color Sensor to use.
In this example, the Color Sensor will print the current brightness to the Brain.
Distance Sensing#
IQ (1st gen)#
To use the IQ (1st gen) Distance Sensing blocks, you must be using an IQ (1st gen) Distance Sensor.
Distance Sensor Found Object#
The Distance Sensor Found Object block is used to report if the Distance Sensor sees an object within its field of view.
The Distance Sensor Found Object block reports True
when the Distance Sensor sees an object or surface within its field of view.
The Distance Sensor Found Object block reports False
when the Distance Sensor does not detect an object or surface.
Choose which Distance Sensor to use.
In this example, when the Distance Sensor detects an object, it will print the distance between it and the detected object.
Object Distance#
The Object Distance block is used to report the distance of the nearest object from the Distance Sensor.
The Object Distance block reports a range from 24mm to 1000mm or 1 inch to 40 inches.
Choose which Distance Sensor to use.
Choose what units to report in: millimeters (mm) or inches.
In this example, when the Distance Sensor detects an object, it will print the distance between it and the detected object.
IQ (2nd gen)#
To use the IQ (2nd gen) Distance Sensing blocks, you must be using an IQ (2nd gen) Distance Sensor.
Object Distance#
The Object Distance block is used to report the distance of the nearest object from the Distance Sensor.
The Object Distance block reports a range from 20mm to 2000mm.
Choose which Distance Sensor to use.
Choose what units to report in: millimeters (mm) or inches.
In this example, when the Distance Sensor detects an object, it will print the distance between it and the detected object.
Object Velocity#
The Object Velocity block is used to report the current velocity of an object in meters per second (m/s).
Choose which Distance Sensor to use.
In this example, the Distance Sensor will report the current velocity of an object moving in front of it.
Object Size Is#
The Object Size Is block is used to report if the Distance Sensor detects the specified object size.
The Distance Sensor determines the size of the object detected (none, small, medium, large) based on the amount of light reflected and returned to the sensor.
The Object Size Is block reports True
when the Distance Sensor detects the specified size.
The Object Size Is block reports False
when the Distance Sensor doesn’t detect the specified size.
Choose which Distance Sensor to use.
Choose which size of the object you want the Object Sensor to check for.
small
medium
large
In this example, if the Distance Sensor detects a small object, it will drive forward until the object is large.
Distance Sensor Found Object#
The Distance Sensor Found Object block is used to report if the Distance Sensor sees an object within its field of view.
The Distance Sensor Found Object block reports True
when the Distance Sensor sees an object or surface within its field of view.
The Distance Sensor Found Object block reports False
when the Distance Sensor does not detect an object or surface.
Choose which Distance Sensor to use.
In this example, when the Distance Sensor detects an object, it will print the distance between it and the detected object.
Optical Sensing#
Set Optical Light#
The Set Optical Light block is used to set the light on the Optical Sensor to on or off. The light lets the Optical Sensor see objects if it is looking at an object in a dark area.
Choose which Optical Sensor to use.
Choose whether to turn the light on or off.
In this example, the Optical Sensor will turn its light on for two seconds before turning it off.
Set Optical Light Power#
The Set Optical Light Power block is used to set the light power of Optical sensor
The The Set Optical Light Power block block accepts a range of 0% to 100%. This will change the brightness of the light on the Optical Sensor. If the light is off, this block will turn the light on.
Choose which Optical Sensor to use.
In this example, the Optical Sensor’s power light is set to 75% before it waits to detect an object to print a message.
Optical Sensor Found Object#
The Optical Sensor Found Object block is used to report if the Optical Sensor detects an object close to it.
The Optical Sensor Found Object block reports True
when the Optical Sensor detects an object close to it.
The Optical Sensor Found Object block reports False
when an object is not within range of the Optical Sensor.
Choose which Optical Sensor to use.
In this example, the Optical Sensor’s power light is set to 75% before it waits to detect an object to print a message.
Optical Sensor Detects Color#
The Optical Sensor Detects Color block is used to report if the Optical Sensor detects the specified color.
The Optical Sensor Detects Color block reports True
when the Optical Sensor detects the specified color.
The Optical Sensor Detects Color block reports False
when the Optical Sensor doesn’t detect the specified color.
Choose which Optical Sensor to use.
Choose which color the Optical Sensor will check for.
In this example, the Optical Sensor will wait until it detects a red color before printing the color on the Brain’s screen.
Optical Sensor Color Name#
The Optical Sensor Color Name block is used to report the name of the color detected by the VEX IQ Optical Sensor.
The Color Name block reports one the following colors:
red
green
blue
yellow
orange
purple
cyan
Choose which Optical Sensor to use.
In this example, the Optical Sensor will wait until it detects a red color before printing the color on the Brain’s screen.
Optical Brightness#
The Optical Brightness block is used to report the amount of light detected by the Optical Sensor.
The Optical Brightness block reports a number value from 0% to 100%.
A large amount of light detected will report a high brightness value.
A small amount of light detected will report a low brightness value.
Choose which Optical Sensor to use.
In this example, the Optical Sensor will print the current brightness value to the Brain’s screen.
Optical Hue#
The Optical Hue block is used to report the hue of the color of an object.
The Optical Hue block reports a number value that is the hue of the color of an object. It returns a number between 0 and 359.
The value can be thought of as the location of the color on a color wheel in degrees.
Choose which Optical Sensor to use.
In this example, the Optical Sensor will print the currently seen hue to the Brain’s screen.
Vision Sensing#
Take Vision Sensor Snapshot#
The Take Vision Sensor Snapshot block is used to take a snapshot from the Vision Sensor.
The Take Vision Sensor Snapshot block will capture the current image from the Vision Sensor to be processed and analyzed for color signatures and codes.
A snapshot is required first before using any other Vision Sensor blocks.
Choose which Vision Sensor to use.
Select which vision signature to use. Vision signatures are configured from the Devices window.
Set Vision Sensor Object Item#
The Set Vision Sensor Object Item block is used to set the object item (of the object you want to learn more information about) out of the number of objects detected.
Choose which Vision Sensor to use.
Vision Sensor Object Count#
The Vision Sensor Object Count block is used to report how many objects the Vision Sensor detects.
The Take Vision Sensor Snapshot block will need to be used before the Vision Sensor Object Count block reports a number of objects.
The Vision Sensor Object Count block will only detect the number of objects from the last snapshot signature.
Choose which Vision Sensor to use.
Vision Sensor Object Exists?#
The Vision Sensor Object Exists? block is used to report if the Vision Sensor detects a configured object.
The Take Vision Sensor Snapshot block will need to be used before the Vision Sensor Object Exists? block can detect any configured objects.
The Vision Sensor Object Exists? block reports True
when the Vision Sensor detects a configured object.
The Vision Sensor Object Exists? block reports False
when the Vision Sensor does not detect a configured object.
Choose which Vision Sensor to use.
Vision Sensor Object#
The Vision Sensor Object block is used to report information about a detected object from the Vision Sensor.
The Take Vision Sensor Snapshot block will need to be used before the Vision Sensor Object Exists? block can detect any configured objects.
Choose which Vision Sensor to use.
Choose which property to report from the Vision Sensor:
width - How wide the object is in pixels, from 2 - 316 pixels.
height - How tall the object is in pixels, from 2 - 212 pixels.
centerX - The center X coordinate of the detected object, from 0 - 315 pixels.
centerY - The center Y coordinate of the detected object, from 0 - 211 pixels.
angle - The angle of the detected object, from 0 - 180 degrees.