So far, you have used sensors to control Hummingbird outputs with if-else statements and while loops. In this lesson, you will learn to use the dial sensor to control Hummingbird outputs directly while practicing while loops with the sound sensor. Start by connecting the dial sensor to port 1, the sound sensor to port 2, and a single color LED to port 1.
Use the getDial() method to find the value of the dial sensor, and the getSound() method to find the value of the sound sensor. Just like the other sensor methods you have used, both of these methods require one parameter, the port to which the sensor is connected (1-3). The getDial() method returns a value from 0-100 that represents the position of the dial. The getSound() method returns a value from 0 to roughly 100 that represents the magnitude of the sound around the sensor in arbitrary units.
Note: If your Hummingbird contains a micro:bit V2, you can also use the sound sensor in the micro:bit by calling getSound(“microbit”). Using the “microbit” parameter will result in an error if your Hummingbird does not have a micro:bit V2.