Measure light intensity
Simulink Support Package for LEGO MINDSTORMS NXT Hardware
This block outputs the intensity of light detected by the NXT Light Sensor. The sensor includes an illuminating LED to actively measure the reflectance of nearby surfaces. For example, the light-intensity under a desk measures approximately 20 while the light-intensity of fluorescent light is approximately 85.
If you run a simulation of a model that contains this block without the target hardware, this block outputs zeros. See Block Produces Zeros or Does Nothing in Simulation.
legonxtlib block library
and copy the blocks shown to a new model.
Connect the Light Sensor block to the LCD block, as shown.
Connect the Light sensor to Port 1 on the NXT brick.
Prepare and run the model on the NXT brick.
Point the Light sensor at a variety of well-lit objects and observe the measurements on the LCD display.
When you point the sensor at a bright light, the measurement value is higher.
When you point the sensor at a dark shadow, the measurement value is lower.
Hold the Light sensor near a piece of white paper in a dark location, such as under your desk. The red LED in the sensor illuminates the paper. Observe the measurements on the LCD display.
When you hold the sensor nearer to the paper, the measurement value is higher.
When you hold the sensor further away from the paper, the measurement value is lower.
Select the NXT sensor port to which the sensor is connected.
Avoid assigning multiple devices to the same port. The options are
Select the type of light intensity data to output:
Normalized (0 - 100) outputs the
intensity of the light on a scale from 0 to 100. 0 is the weakest
intensity. 100 is the strongest intensity.
Raw A/D (1023 - 0) outputs the intensity
of the light on a scale from 1023 to 0. 1023 is the weakest intensity.
0 is the strongest intensity.
Emit red light from the LED located next to the light sensor. Under low light conditions, the sensor can use this capability to measure the amount of red light nearby objects reflect.
Specify how often the block reads sensor values.
Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.