ColorSensor doesn't work

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

ColorSensor doesn't work

Postby Hattusas » Sat Oct 06, 2007 11:37 am

Greetings everyone.I have joined LegoMindstorm world and have been trying to test the sensors.

I managed to test the motors , it was simple indeed to create a new instance with MotorPort.A and sending the forward() method.

But however ColorSensor buzzed me a lot.
Here is the simple code I produced:

Code: Select all
import lejos.nxt.*;
public class ColorTest {

   /**
    * @param args
    */
   public static void main(String[] args) throws Exception{
      // TODO Auto-generated method stub
       ColorSensor colorSensor = new ColorSensor(SensorPort.S1);
      // SensorPort.S1.activate();
     
       while (true){
        // colorSensor.getData(0x41, new byte[3], 4);
         LCD.drawString("Green: "+colorSensor.getGreen(), 2, 2);
         LCD.refresh();
         Thread.sleep(200);
         LCD.clear();
       }
   }

}


When I upload it via Eclipse the LCD always prints out : 255
The fog light of the sensor is ON. But I was expecting to get results other than 255 . :roll:

Could you lead me?

Thank you.
Today is the first day of rest of your life.
Hattusas
New User
 
Posts: 12
Joined: Sat Oct 06, 2007 11:24 am

Postby Hattusas » Sat Oct 06, 2007 11:40 am

Additionally how should I use the getData command?
I am sure the suitable parameters for the arguments :?:
Today is the first day of rest of your life.
Hattusas
New User
 
Posts: 12
Joined: Sat Oct 06, 2007 11:24 am

Postby Hattusas » Sat Oct 06, 2007 12:44 pm

The first question is invalid anymore. When I installed the firmware again it worked.

But however I am still wondering about the getData method. Any help please?
Today is the first day of rest of your life.
Hattusas
New User
 
Posts: 12
Joined: Sat Oct 06, 2007 11:24 am

Postby mdsmitty » Sun Oct 07, 2007 8:22 pm

getData() is extended from I2CSensor. The only methods you have to worry about is getBlue(), getRed(), getGreen() and getColor().
mdsmitty
Novice
 
Posts: 77
Joined: Tue Feb 27, 2007 3:07 am


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 1 guest

more stuff