Package lejos.nxt

Examples of lejos.nxt.LightSensor


  }

  private SensorActorController() {
    motorLeft = new NXTRegulatedMotor(MotorPort.A);
    motorRight = new NXTRegulatedMotor(MotorPort.C);
    lightSensorLeft = new LightSensor(SensorPort.S1);
    lightSensorRight = new LightSensor(SensorPort.S4);
    lightSensorLeft.setHigh(lightMax);
    lightSensorLeft.setLow(lightMin);
    lightSensorRight.setHigh(lightMax);
    lightSensorRight.setLow(lightMin);
    lightSensorLeft.setFloodlight(false);
View Full Code Here


   
//    LCD.drawString("SensorPort 1 Value: " + SensorPort.S1.readValue(), 1, 2);
    System.out.println("S1 Value: " + SensorPort.S1.readValue());
    System.out.println("S1 RawValue: " + SensorPort.S1.readRawValue());
   
    LightSensor light =  new LightSensor(SensorPort.S1, true); //Hierdurch wird der Port1 ersetzt, MySensorPort ist dann nicht mehr richtig die Quelle?
    System.out.println("light: Value=" + light.readValue() + " NormalizedValue=" + light.readNormalizedValue());
     
//    System.out.println("light.readValue in Cerca.java:" + light.readValue());
//    LCD.drawString("SensorPort 1 Value: " + SensorPort.S1.readValue(), 1, 2);
    System.out.println("S1 Value: " + SensorPort.S1.readValue());
    System.out.println("S1 RawValue: " + SensorPort.S1.readRawValue());
View Full Code Here

  public void testCercaContext() {
    NativeSensorPortStub nativeSensorPortStub = new NativeSensorPortStub();
    nativeSensorPortStub.setISensorPort(0, lightSensorStub);
    NativeSensorPort nativeSensorPort = NativeSensorPort.getInstance();
    nativeSensorPort.setBehaviour(nativeSensorPortStub);
    LightSensor lightSensor = new LightSensor(SensorPort.S1);

    lightSensorStub.setImage(new Image(Display.getDefault(),
        "src/de/nordakademie/nxtsimulation/"
            + "test/LightSensorTestImage_white.png"));
    // sollte 100%-Helligkeit sein
    lightSensorStub.setPosX(50);
    lightSensorStub.setPosY(50);
    int brightness = lightSensor.readValue();
    assertEquals(100, brightness);
   
    lightSensorStub.setImage(new Image(Display.getDefault(),
        "src/de/nordakademie/nxtsimulation/"
        + "test/LightSensorTestImage_gray.png"));
    // sollte 50%-Helligkeit sein
    lightSensorStub.setPosX(50);
    lightSensorStub.setPosY(50);
    brightness = lightSensor.readValue();
    assertEquals(50, brightness, 1);
   
    lightSensorStub.setImage(new Image(Display.getDefault(),
        "src/de/nordakademie/nxtsimulation/"
            + "test/LightSensorTestImage_black.png"));
    // sollte 0%-Helligkeit sein
    lightSensorStub.setPosX(50);
    lightSensorStub.setPosY(50);
    brightness = lightSensor.readValue();
    assertEquals(0, brightness);
   
    lightSensorStub.setImage(new Image(Display.getDefault(), 10, 10));
    // sollte 0%-Helligkeit sein, da Position au�erhalb des Bildes
    lightSensorStub.setPosX(50);
    lightSensorStub.setPosY(50);
    brightness = lightSensor.readValue();
    assertEquals(0, brightness);
  }
View Full Code Here

      public void setPowerType(int portType) {
        assertEquals(0, portType);
      }

    });
    light = new LightSensor(SensorPort.S1, true);
  }
View Full Code Here

      public void setPowerType(int portType) {
        assertEquals(0, portType);
      }

    });
    light = new LightSensor(SensorPort.S1, false);
  }
View Full Code Here

      public void setPowerType(int portType) {
        assertEquals(0, portType);
      }

    });
    light = new LightSensor(SensorPort.S1, false);
    light.readValue();
  }
View Full Code Here

    if (lightPort == null || colorPort == null) {
      throw new UnsupportedOperationException("Light or Color Ports invalid")
    }
   
    else if (light == null) {
      ls = new LightSensor(lightPort);
      cs = new ColorHTSensor(colorPort);
      light = new Light();
      de = SumoDataExchange.getInstance();
     
      ls.setFloodlight(true);
View Full Code Here

  //Constructor takes in an int.  0 returns a DifferentialPilot object, 1 returns a
  //RotateMoveController object
  public Robot(){
    left = Motor.C;
    right = Motor.A;
    light = new LightSensor(SensorPort.S1);
    pilot = new DifferentialPilot(2.2f, 6.875f, left, right);
    left.setSpeed(defaultSpeed);
    right.setSpeed(defaultSpeed);
   
  }
View Full Code Here

TOP

Related Classes of lejos.nxt.LightSensor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.