1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5 <!-- Generated by javadoc (build 1.5.0_09) on Fri Mar 30 18:53:06 BST 2007 -->
7 LightSensor (leJOS NXT API documentation)
10 <META NAME="keywords" CONTENT="lejos.nxt.LightSensor class">
12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
14 <SCRIPT type="text/javascript">
15 function windowTitle()
17 parent.document.title="LightSensor (leJOS NXT API documentation)";
25 <BODY BGCOLOR="white" onload="windowTitle();">
28 <!-- ========= START OF TOP NAVBAR ======= -->
29 <A NAME="navbar_top"><!-- --></A>
30 <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
31 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
33 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
34 <A NAME="navbar_top_firstrow"><!-- --></A>
35 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
36 <TR ALIGN="center" VALIGN="top">
37 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
38 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
39 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
42 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
47 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
53 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
54 <A HREF="../../lejos/nxt/LCD.html" title="class in lejos.nxt"><B>PREV CLASS</B></A>
55 <A HREF="../../lejos/nxt/ListenerCaller.html" title="interface in lejos.nxt"><B>NEXT CLASS</B></A></FONT></TD>
56 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
57 <A HREF="../../index.html?lejos/nxt/LightSensor.html" target="_top"><B>FRAMES</B></A>
58 <A HREF="LightSensor.html" target="_top"><B>NO FRAMES</B></A>
59 <SCRIPT type="text/javascript">
62 document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
67 <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
74 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
75 SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
76 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
77 DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
80 <A NAME="skip-navbar_top"></A>
81 <!-- ========= END OF TOP NAVBAR ========= -->
84 <!-- ======== START OF CLASS DATA ======== -->
89 Class LightSensor</H2>
91 <A HREF="../../java/lang/Object.html" title="class in java.lang">java.lang.Object</A>
92 <IMG SRC="../../resources/inherit.gif" ALT="extended by "><B>lejos.nxt.LightSensor</B>
95 <DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../lejos/nxt/SensorConstants.html" title="interface in lejos.nxt">SensorConstants</A></DD>
99 <DT><PRE>public class <B>LightSensor</B><DT>extends <A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A><DT>implements <A HREF="../../lejos/nxt/SensorConstants.html" title="interface in lejos.nxt">SensorConstants</A></DL>
103 Abstraction for a NXT light sensor.
104 The light sensor can be calibrated to low and high values.
111 <!-- =========== FIELD SUMMARY =========== -->
113 <A NAME="field_summary"><!-- --></A>
114 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
115 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
116 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
117 <B>Field Summary</B></FONT></TH>
120 <A NAME="fields_inherited_from_class_lejos.nxt.SensorConstants"><!-- --></A>
121 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
122 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
123 <TH ALIGN="left"><B>Fields inherited from interface lejos.nxt.<A HREF="../../lejos/nxt/SensorConstants.html" title="interface in lejos.nxt">SensorConstants</A></B></TH>
125 <TR BGCOLOR="white" CLASS="TableRowColor">
126 <TD><CODE><A HREF="../../lejos/nxt/SensorConstants.html#MODE_ANGLESTEP">MODE_ANGLESTEP</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_BOOLEAN">MODE_BOOLEAN</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_CELSIUS">MODE_CELSIUS</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_FARENHEIT">MODE_FARENHEIT</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_PCTFULLSCALE">MODE_PCTFULLSCALE</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_PERIODCOUNTER">MODE_PERIODCOUNTER</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_RAW">MODE_RAW</A>, <A HREF="../../lejos/nxt/SensorConstants.html#MODE_TRANSITIONCNT">MODE_TRANSITIONCNT</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_ANGLE">TYPE_ANGLE</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_CUSTOM">TYPE_CUSTOM</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_LIGHT_ACTIVE">TYPE_LIGHT_ACTIVE</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_LIGHT_INACTIVE">TYPE_LIGHT_INACTIVE</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_LOWSPEED">TYPE_LOWSPEED</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_LOWSPEED_9V">TYPE_LOWSPEED_9V</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_NO_SENSOR">TYPE_NO_SENSOR</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_REFLECTION">TYPE_REFLECTION</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_SOUND_DB">TYPE_SOUND_DB</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_SOUND_DBA">TYPE_SOUND_DBA</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_SWITCH">TYPE_SWITCH</A>, <A HREF="../../lejos/nxt/SensorConstants.html#TYPE_TEMPERATURE">TYPE_TEMPERATURE</A></CODE></TD>
130 <!-- ======== CONSTRUCTOR SUMMARY ======== -->
132 <A NAME="constructor_summary"><!-- --></A>
133 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
134 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
135 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
136 <B>Constructor Summary</B></FONT></TH>
138 <TR BGCOLOR="white" CLASS="TableRowColor">
139 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#LightSensor(lejos.nxt.ADSensorPort)">LightSensor</A></B>(lejos.nxt.ADSensorPort port)</CODE>
142 Create a light sensor object attached to the specified port.</TD>
144 <TR BGCOLOR="white" CLASS="TableRowColor">
145 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#LightSensor(lejos.nxt.ADSensorPort, boolean)">LightSensor</A></B>(lejos.nxt.ADSensorPort port,
146 boolean floodlight)</CODE>
149 Create a light sensor object attached to the specified port,
150 and sets floodlighting on or off.</TD>
154 <!-- ========== METHOD SUMMARY =========== -->
156 <A NAME="method_summary"><!-- --></A>
157 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
158 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
159 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
160 <B>Method Summary</B></FONT></TH>
162 <TR BGCOLOR="white" CLASS="TableRowColor">
163 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
164 <CODE> void</CODE></FONT></TD>
165 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#calibrateHigh()">calibrateHigh</A></B>()</CODE>
168 call this method whtn the light sensor is reading the high value - used by reaeValue</TD>
170 <TR BGCOLOR="white" CLASS="TableRowColor">
171 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
172 <CODE> void</CODE></FONT></TD>
173 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#calibrateLow()">calibrateLow</A></B>()</CODE>
176 call this method when the light sensor is reading the low value - used by readValue</TD>
178 <TR BGCOLOR="white" CLASS="TableRowColor">
179 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
180 <CODE> int</CODE></FONT></TD>
181 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#readNormalizedValue()">readNormalizedValue</A></B>()</CODE>
184 Read the current sensor normalized value.</TD>
186 <TR BGCOLOR="white" CLASS="TableRowColor">
187 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
188 <CODE> int</CODE></FONT></TD>
189 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#readValue()">readValue</A></B>()</CODE>
192 Read the current sensor value.</TD>
194 <TR BGCOLOR="white" CLASS="TableRowColor">
195 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
196 <CODE> void</CODE></FONT></TD>
197 <TD><CODE><B><A HREF="../../lejos/nxt/LightSensor.html#setFloodlight(boolean)">setFloodlight</A></B>(boolean floodlight)</CODE>
200 Set floodlighting on or off.</TD>
203 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
204 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
205 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
206 <TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></B></TH>
208 <TR BGCOLOR="white" CLASS="TableRowColor">
209 <TD><CODE><A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A></CODE></TD>
215 <!-- ========= CONSTRUCTOR DETAIL ======== -->
217 <A NAME="constructor_detail"><!-- --></A>
218 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
219 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
220 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
221 <B>Constructor Detail</B></FONT></TH>
225 <A NAME="LightSensor(lejos.nxt.ADSensorPort)"><!-- --></A><H3>
228 public <B>LightSensor</B>(lejos.nxt.ADSensorPort port)</PRE>
230 <DD>Create a light sensor object attached to the specified port.
231 The sensor will be set to floodlit mode, i.e. the LED will be turned on.
234 <DT><B>Parameters:</B><DD><CODE>port</CODE> - port, e.g. Port.S1</DL>
238 <A NAME="LightSensor(lejos.nxt.ADSensorPort, boolean)"><!-- --></A><H3>
241 public <B>LightSensor</B>(lejos.nxt.ADSensorPort port,
242 boolean floodlight)</PRE>
244 <DD>Create a light sensor object attached to the specified port,
245 and sets floodlighting on or off.
248 <DT><B>Parameters:</B><DD><CODE>port</CODE> - port, e.g. Port.S1<DD><CODE>floodlight</CODE> - true to set floodit mode, false for ambient light.</DL>
251 <!-- ============ METHOD DETAIL ========== -->
253 <A NAME="method_detail"><!-- --></A>
254 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
255 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
256 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
257 <B>Method Detail</B></FONT></TH>
261 <A NAME="setFloodlight(boolean)"><!-- --></A><H3>
264 public void <B>setFloodlight</B>(boolean floodlight)</PRE>
266 <DD>Set floodlighting on or off.
272 <DT><B>Parameters:</B><DD><CODE>floodlight</CODE> - true to set floodit mode, false for ambient light.</DL>
277 <A NAME="readValue()"><!-- --></A><H3>
280 public int <B>readValue</B>()</PRE>
282 <DD>Read the current sensor value.
283 Use calibrateLow() to set the zero level, and calibrateHigh to set the 100 level.
290 <DT><B>Returns:</B><DD>Value as a percentage of difference between the low and high calibration values.</DL>
295 <A NAME="readNormalizedValue()"><!-- --></A><H3>
296 readNormalizedValue</H3>
298 public int <B>readNormalizedValue</B>()</PRE>
300 <DD>Read the current sensor normalized value. Allows more accuracy
301 than readValue(). For LEGO sensor, values typically range from
302 145 (dark) to 890 (sunlight).
309 <DT><B>Returns:</B><DD>Value as raw normalized (0 to 1023)</DL>
314 <A NAME="calibrateLow()"><!-- --></A><H3>
317 public void <B>calibrateLow</B>()</PRE>
319 <DD>call this method when the light sensor is reading the low value - used by readValue
330 <A NAME="calibrateHigh()"><!-- --></A><H3>
333 public void <B>calibrateHigh</B>()</PRE>
335 <DD>call this method whtn the light sensor is reading the high value - used by reaeValue
344 <!-- ========= END OF CLASS DATA ========= -->
348 <!-- ======= START OF BOTTOM NAVBAR ====== -->
349 <A NAME="navbar_bottom"><!-- --></A>
350 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
351 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
353 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
354 <A NAME="navbar_bottom_firstrow"><!-- --></A>
355 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
356 <TR ALIGN="center" VALIGN="top">
357 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
358 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
359 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
360 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
361 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
362 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
363 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
367 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
373 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
374 <A HREF="../../lejos/nxt/LCD.html" title="class in lejos.nxt"><B>PREV CLASS</B></A>
375 <A HREF="../../lejos/nxt/ListenerCaller.html" title="interface in lejos.nxt"><B>NEXT CLASS</B></A></FONT></TD>
376 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
377 <A HREF="../../index.html?lejos/nxt/LightSensor.html" target="_top"><B>FRAMES</B></A>
378 <A HREF="LightSensor.html" target="_top"><B>NO FRAMES</B></A>
379 <SCRIPT type="text/javascript">
382 document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
387 <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
394 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
395 SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
396 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
397 DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
400 <A NAME="skip-navbar_bottom"></A>
401 <!-- ======== END OF BOTTOM NAVBAR ======= -->