Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.
Anthony Law edited this page Apr 11, 2016 · 5 revisions

First of all, again, you have to create a LegoPort for you sensor, mentioned in LegoPort

LegoPort port = new LegoPort(LegoPort.INPUT_1); //Input 1 is sensor port 1

Touch Sensor

  1. Import the TouchSensor class

    import ev3dev.hardware.sensors.TouchSensor
  2. Create a touch sensor instance and play with it.

    TouchSensor touch = new TouchSensor(port);
    while(true){
        if (touch.isPressed()){
            System.out.println("Pressed!");
        }
    }

Color Sensor

  1. Import the ColorSensor class

    import ev3dev.hardware.sensors.ColorSensor
  2. Create a touch sensor instance and play with it.

    ColorSensor color = new ColorSensor(port);
    //...further more later. 
Clone this wiki locally