CalibrateColor
Enables calibration mode of the HiTechnic color sensor V1
Contents
Syntax
CalibrateColor(port, mode)
CalibrateColor(port, mode, handle)
Description
Do not use this function with the HiTechnic Color Sensor V2. It has a bright white flashing LED. This function is intended for the HiTechnic Color Sensor V1 (milky, weak white LED).
Calibrate the color sensor with white and black reference value. It's not known whether calibration of the color sensor makes sense. HiTechnic doku says nothing, some people say it is necessary, but it works and has effect ;-). The sensor LEDs make a short flash after successful calibration. When calibrated, the sensor keeps this information in non-volatile memory. There are two different modes for calibration:
- mode = 1: white balance calibration Puts the sensor into white balance calibration mode. For best results the sensor should be pointed at a diffuse white surface at a distance of approximately 15mm before calling this method. After a fraction of a second the sensor lights will flash and the calibration is done.
- mode = 2: black level calibration Puts the sensor into black/ambient level calibration mode. For best results the sensor should be pointed in a direction with no obstacles for 50cm or so. This reading the sensor will use as a base level for other readings. After a fraction of a second the sensor lights will flash and the calibration is done. When calibrated, the sensor keeps this information in non-volatile memory.
The color sensor has to be opened (using OpenColor) before execution.
The given port number specifies the connection port. The value port can be addressed by the symbolic constants SENSOR_1 , SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick.
The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).
Example
% color must be open for calibration OpenColor(SENSOR_2); % white calibration mode CalibrateColor(SENSOR_2, 1); % pause for changing position pause(5); % black calibration mode CalibrateColor(SENSOR_2, 2);
See also
OpenColor, GetColor, CloseSensor,
Signature
- Author: Rainer Schnitzler, Linus Atorf (see AUTHORS)
- Date: 2010/09/16
- Copyright: 2007-2010, RWTH Aachen University