Been learning robotics in university for just over 2 years, our course focuses entirely on lejos so I know "some", but there is so much more to know.
The basic question : "running the program via the pcapi over USB, code that worked on the brick itself locally now no longer works. It is very simply designed to output the ColorSensor RGB values from the brick to System.out on the machine"
When I run this (I will post my code, but its basically the SensorTest sample but for ColorSensor), any of the getRed(), getBlue(), getGreen() returns 0. But if I were to getColorID() it will return those values. Unfortunately I require the RGB values for my project so receiving the stock 6 colours isn't enough.
Short of progressing to working out I2C buffer lengths and checking to see if these are being entirely sent back via LCP I don't know where to go from here...
Thank you very much for help provided.
Info : NXT brick 2.0, OS X Lion, 0.9.0 rev. 4498
SOURCE:
- Code: Select all
import lejos.nxt.*;
import lejos.nxt.addon.EOPD;
import lejos.nxt.remote.NXTCommand;
import lejos.pc.comm.*;
public class SensorTest{
public static void main(String[] args) {
EOPD distance = new EOPD(SensorPort.S3,true);
ColorSensor colour = new ColorSensor(SensorPort.S2);
ColorSensor.Color temp;
while(true) {
temp = colour.getColor();
int test = colour.getColorID();
String RGB = "R" + Integer.toString(temp.getRed()) + " G" + Integer.toString(temp.getGreen()) + " B" + Integer.toString(temp.getBlue());
System.out.println("distance = " + distance.processedValue());
System.out.println(RGB);
System.out.println(test);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {}
}
}
}
