How to Write your own Flight Controller Software — Part 2
A Diversion down Hardware Lane
Before proceeding with the flight controller software, we need to sort out a couple of hardware issues. These are, controlling a buzzer (i.e. a passive piezo) and understanding remote control inputs via SBUS.
The Buzzer Issue
Why can’t we just connect a piezo to a pin on our Nano and use PWM to create a tone? I’m glad you asked! The biggest problem is current limits on the I/O pins. If you have a look at the pinout information for the Nano 33 IoT, you will see that the maximum current per pin is 7mA. For the Nano 33 BLE, maximum output current is 15 mA, maximum input current is 5 mA and the maximum total current for the MCU and all GPIO’s is 25 mA.
We have selected the PS1440P02BT Piezo (Figure 1) as our noise maker. The data sheet doesn’t provide the current rating for the piezo, possibly because it varies with the voltage used. For 3.3V, the typical maximum current drawn for these devices is 9–14 mA, which is too much for our Nano. Thus we need to drive it via a transistor. Our buzzer driver circuit is shown in Figure 2.