In the last lesson, you learned to use the Hummingbird light sensor. You will learn to use the distance sensor in this lesson. Any sensor can be connected to any of the three “SENSORS” ports on the Hummingbird Bit. Connect the distance sensor to port 1 and a tri-color LED to port 1.
Use the getDistance() method to find the value of the distance sensor; it requires one parameter, the port to which the sensor is connected (1-3). The getDistance() method returns the distance to the closest object in centimeters. The range of the Hummingbird distance sensor is approximately 2-200 cm. The distance sensor cannot measure an object that is pressed directly against it; make sure the object is at least 1 cm away.