NodeMCU Projects: Difference between revisions

Content added Content deleted
Line 111: Line 111:


*Control a hobby servo
*Control a hobby servo

Hobby servo motors can be controlled using PWM.
They require a frequency of 50Hz and a duty between about 40 and 115, with 77 being the center value.

<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
servo = machine.PWM(machine.Pin(12), freq=50)
servo = machine.PWM(machine.Pin(12), freq=50)