Objective
To learn to use the light sensor and to monitor the light sensor using the Front Panel on LabView.
Final Program
Figure : The final block diagram to display the intensity and switch on/off the light on the sensor.
Figure : Front Panel showing the switch for the light and the intensity display.
Light sensor block
The light sensor block is a part of the input blocks in the NXT Toolkit. You can insert a light sensor block by opening the Functions Palette -> Addons -> NXT Toolkit -> NXT Library -> Input. Note that the input terminal says that the Port should be Port 3.
Figure : Light Sensor block in the NXT Toolkit on LabView.
Figure: Light Sensor terminals
Converting number to strings
To display the intensity on the display of the brick, it needs to be in the string format, whereas the light sensor gives the intensity in a number format. To convert a number to string, we use the Number to String conversion block.
Writing the program
Close existing VI's and open a new VI from the Getting Started window. Insert a while loop, and into this, insert a Light Sensor block and a Display Text block. Insert a Number to String conversion block and wire it to the Text terminal on the Display Text block. Wire the Intensity terminal on the Light Sensor block to the number terminal on the Number to String conversion block.
Inserting Control and Indicator
To control the Light sensor and to indicate the intensity on the Front Panel, we need to include two blocks which will do these tasks. To do this, on the Generate Light terminal of the Light Sensor block, right click and select Create-> Control in the dropdown menu to insert a Floodlight box. You will see that this will insert a switch on the Front Panel.
To display the intensity on the Front Panel, we need to insert a Intensity Indicator. To do this, move the cursor near the wire between Intensity terminal and the Number to String conversion block until you see a wire spool cursor. Now right click and Create-> Indicator to insert the Intensity Indicatior.
Once this is done, the program is almost done, and you need to download the firmware on to the brick. While downloading the firmware keep the cable connected and choose Debug on the NXT Terminal.
Figure : Select Debug on the NXT Terminal window
Figure : Typical Intensity display on the Front Panel
You will be able to see the intensity real time on the Front Panel. Lookup the Chapter 2 and the last section to replace your Intensity display on the Front Panel with a chart.