We are close to building our IoT weather dashboard. The final steps involve controlling our servo position based on the weather data returned from the Yahoo! Weather web service and physically building a backdrop for our servo needle.
As some of you may have noticed, your servo motor does not move a full 180 degrees from minimum to maximum. This is due to the minimum and maximum pulse widths of 1 ms and 2 ms set in GPIO Zero. To account for this difference, we must adjust the min_pulse_width
and max_pulse_width
properties accordingly when we instantiate a Servo
object.
The following code does just that. The variable, servoCorrection
, adds to and subtracts from the min_pulse_width
and max_pulse_width
values. The following code moves the servo to the minimum position and then the maximum position after 5
seconds:
- Open up Thonny from
Application Menu
|Programming
|Thonny Python IDE
. - Click on the
New
icon to create a new file.
- Type...