i have some trouble with the ColorLightSensor. We have 3 Sensors but only 1 is working with LeJos. I tried all 3 with the LEGO Firmware, they work without any error.... dont know why ? anybody else have the same Problem ?
- Code: Select all
package org.lejos.example;
import lejos.nxt.*;
import lejos.nxt.addon.ColorSensor;
import lejos.robotics.ColorDetector;
import lejos.robotics.Colors;
import lejos.robotics.Colors.*;
import lejos.util.TextMenu;
/**
* Example leJOS Project with an ant build file
*
*/
public class nxtTest {
final static int INTERVAL = 500; // milliseconds
public static void main(String [] args) throws Exception {
String ports[] = {"Port1", "Port2", "Port3", "Port4"};
TextMenu tmenu = new TextMenu(ports, 2, "Waehle Anschlussport");
ColorLightSensor clsens = new ColorLightSensor(SensorPort.PORTS[tmenu.select()],ColorLightSensor.TYPE_COLORFULL);
while(!Button.ESCAPE.isPressed()) {
LCD.clear();
Colors.Color color = clsens.readColor();
LCD.drawString(color.name(), 7, 6);
LCD.refresh();
Thread.sleep(INTERVAL);
}
}
}
