colordetector.java
来自「专业汽车级嵌入式操作系统OSEK的源代码」· Java 代码 · 共 31 行
JAVA
31 行
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 + =
减小字号Ctrl + -
显示快捷键?