hello dear all - well that would be great
Hello, has anyone tested the library on ESP32 ?
I have some trouble to make it work.
i would love to use it on esp32
BTW one question
: - do we need that library - cannot we just start without that... - cf this post:
https://icircuit.net/micropython-contro ... demcu/2385
Servos are exciting devices. We can get precise posting with minimal code,
all we need is a controller that can produce PWM at 50Hz.
In this post we will understand how to use ESP32 to control Servo.
We will be using micropython to program ESP32/NodeMCU.
The grate thing about MicroPython is that it is platform independent (mostly),
which means code written for NodeMCU (ESP8266) can be used on ESP32 as well.
To use MicroPython on ESP32, First we need to load MicroPython Interpreter. Check out ESP32
– Getting started with MicroPython post to load interpreter and tools you can use with micro python. https://icircuit.net/esp32-micropython- ... arted/1999
If you are using NodeMCU, then refer to this post https://icircuit.net/nodemcu-getting-st ... ython/2406
MicroPython has PWM support. You can find full documentation of PWM library here http://docs.micropython.org/en/latest/e ... l/pwm.html
we need a ESP32 or NodeMCU
Machine with uPyCraft to load python files to the device
Connect servo signal pin to GPIO2 of the ESP, you need to power the servo as well
Code: All you need is couple of python lines to control the servo, how easy is that
Code: Select all
p4 = machine.Pin(4)
servo = machine.PWM(p4,freq=50)
# duty for servo is between 40 - 115
The PWM method of machine takes two inputs, the pin to which we want connect servo
(in case of ESP8266 we can choose one from 0, 2, 4, 5, 12, 13, 14 and 15) and frequency of the PWM signal.
Most of the hobby servos work with 50Hz PWM, so we choose that. Then we can use duty method to set the anglewe can call servo.duty() method to change the set the servo angle
love to hear from you