This is a very short project about how to drive a servo. The default inbox driver has to be replaced first to the DMAP driver and then it should run properly.
It has a slider and a textbox to set the angle or the pulse width. They are synchronized and if you put wrong value in the textbox it throws an exception. If the check box is checked the servo will follow the slider and If not, you have to move it with the '
I've made two servo class. First one called '
Servo' seems to be better one. It starts the PWM pin at the initialization process and stops it when the dispose method is called. The second one called '
Servo2' stops the PWM pin after every movement and a timer periodically refresh the state because the servo can be moved by outer forces.
When you attach a new servo you have to specify the parameters from the documentation (they are not accurate with the SG90) and If the servo consume more than 5V (or lag appears when you want It to move) you have to add an outer power supply. Here are two pictures to help you out.
So the default values in the Servo's constructor should look like the following code because of the frequency, duty cycle and it's a 180 degree servo:
public Servo(int pinNumber, int frequency = 50, double minPulseWidth = 1, double maxPulseWidth = 2, int maxAngle = 180, int signalDuration = 40)
But if you want it to work well you can adjust it at creation of the Servo class:
s = new Devices.Servo(pinNumber: 5, minPulseWidth: 0.7 ,maxPulseWidth: 2.6);