As in week 9, interfacing the output device to the microcontroller is easy when they are available libraries that do the hard work for us...
I simply use the demo code "sweep_test" from BARRAGAN as a programming process:
Include the library "Servo"
Define the object "myservo".
Define the integer "pos".
In the setup function attach the "myservo" object to pin 6. (PWM pin for arduino board and atmel A328p)
In the loop function
Do a for loop for pos starting at 0 and ending at 180 with an increase step of 1 to move the servo from 0 to 180 degree with a delay of 15 milliseconds between each degree.
Do a for loop for pos starting at 180 and ending at 0 with a decrease step of 1 to move the servo from 180 to 0 degree with a delay of 15 milliseconds between each degree.
The video below shows a longer single sweep.
Servo rotation
Add and program an output device to a commercial board
Work done during Covid lockdown
In this section, we will use a raspberry pi 3 with a NAVIO2 hat from EMLID to control servo of a drone.
Figure 6 shows a snapshot of the code
Video 1 shows IMU reading from Navio2 placed inside a fixed wing drone.