⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rcxlightsensor.java

📁 专业汽车级嵌入式操作系统OSEK的源代码
💻 JAVA
字号:
package lejos.nxt;/** * Abstraction for an RCX light sensor. *  */public class RCXLightSensor implements SensorConstants {	LegacySensorPort port;		/**	 * Create an RCX light sensor object attached to the specified port.	 * The sensor will be activated, i.e. the LED will be turned on.	 * @param port port, e.g. Port.S1	 */	public RCXLightSensor(LegacySensorPort port)	{		this.port = port;		port.setTypeAndMode(TYPE_REFLECTION,                            MODE_PCTFULLSCALE);	}		/**	  * Activates an RCX light sensor. This method should be called	  * if you want to get accurate values from an RCX	  * sensor. In the case of RCX light sensors, you should see	  * the LED go on when you call this method.	  */	public void activate()	{		port.activate();	}		/**     * Passivates an RCX light sensor. 	 */	public void passivate()	{		port.passivate();	}		/**	 * Read the current sensor value.	 * @return Value as a percentage.	 */	public int readValue()	{		return ((1023 - port.readRawValue()) * 100/ 1023);  	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -