Servo ver4 (underconstruction)

While this is a stub

"int": 0 — - we read the value from the analog constantly or every int second, if this function is enabled
"pin": 12 — - pin for the servo
"apin": -1, — pin for removing analog, at = -1 the function is disabled
"amap": "0, 4096, 0, 180" — settings for converting analog values to the desired server range, it makes sense if analog is enabled

Everything is just right) in the module everything is there. Please note that the analog can be turned off by setting = -1, then only changing the position by value will work. Either by setting serv = 45; in the script, or by using the slider widget. You're right, you could stop there and read the analog in the script and pass it on to serv, but this will be clocked for at least one second. In the module, when using an analog, you can set int = 0; then the reaction will be instantaneous.

it should work like this too servo = 160;

Servo-a class for controlling servomotors connected to ESP32 pins. int attach (pin) — attaches this GPIO pin to the next free channel.

(channels that were previously disabled are used first),
returns the channel number, or 0 in case of failure. All contact numbers are allowed,
but only contacts are recommended 2,4,12-19,21-23,25-27,32-33.
if btn1==1 then servo = 160; if btn2==1 then servo = 20; if btn3==1 then servo = 90; if btn4==1 then servo = 130;

Added the ability to get the average value for an interval to the analog sensor. avgSteps = 1-works as usual, reads raw data as it is avgSteps > 1-sets the number of analog pin measurements for averaging and then saves it to value. The servo has become much more stable. method for linking a servo and a tax sensor: if analog > 0 then servo = analog;

Leave a Comment

Supported the project — saved a DIY maker! And we accept gifts...

X