NXT 2.0 ColorLightSensor

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: 99jonathan, roger, imaqine

NXT 2.0 ColorLightSensor

Postby smex » Tue Nov 17, 2009 11:38 am

Hi all,

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);
      }
   }
}
smex
New User
 
Posts: 5
Joined: Tue Nov 17, 2009 11:34 am

Postby gloomyandy » Tue Nov 17, 2009 12:04 pm

User avatar
gloomyandy
leJOS Team Member
 
Posts: 4180
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby smex » Tue Nov 17, 2009 12:13 pm

Thanks a lot ! it now works with the new classes ..... sorry for this unnecessary post ^^
smex
New User
 
Posts: 5
Joined: Tue Nov 17, 2009 11:34 am


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff