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

📄 colordetector.java

📁 专业汽车级嵌入式操作系统OSEK的源代码
💻 JAVA
字号:
import lejos.nxt.*;

/**
 * For testing the HiTechnic color sensor (see lejos.nxt.ColorSensor).
 * @author BB
 */
public class ColorDetector {

	final static int INTERVAL = 200; // milliseconds
	
	public static void main(String [] args) throws Exception {
		ColorSensor cmps = new ColorSensor(SensorPort.S1);
		
		while(!Button.ESCAPE.isPressed()) {
			LCD.clear();
			LCD.drawString(cmps.getProductID(), 0, 0);
			LCD.drawString(cmps.getSensorType(), 0, 1);
			LCD.drawString(cmps.getVersion(), 9, 1);
			LCD.drawString("Color", 0, 3);
			LCD.drawInt((int)cmps.getColorNumber(),7,3);
			LCD.drawString("R", 0, 5);
			LCD.drawInt((int)cmps.getRed(),1,5);
			LCD.drawString("G", 5, 5);
			LCD.drawInt((int)cmps.getGreen(),6,5);
			LCD.drawString("B", 10, 5);
			LCD.drawInt((int)cmps.getBlue(),11,5);
			LCD.refresh();
			Thread.sleep(INTERVAL);
		}
	}
}

⌨️ 快捷键说明

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