Handling multiple analog devices
After going through the PWM signals section, it is now time to connect more than one analog device to the Micro:bit. In this section, we will connect two analog devices, one as an input with read_analog()
and another as an output device controlled with write_analog()
. In Figure 9.8, at pin 0, a potentiometer is connected, and at pin 1, a servo motor is connected. Both devices are provided with a 3 V supply to complete the electrical circuit. To control the servo motor, a potentiometer passes the voltage levels acting as input values to the servo motor. The servo motor will rotate according to the input from the potentiometer:
Figure 9.8 – Connecting the potentiometer as input device and the servo motor as an output device to the Micro:bit
Figure 9.9 shows both a program and its output in the shell window:
Figure 9.9 – Operating the servo motor through a potentiometer using the Micro:bit
...