Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By penatenjoe
#13451 I have some Arduino projects which are using an ESP8266-modem but which now can run on the ESP8266 itself! I love this new platform and many things work like a charm. One of my projects is using servos as mechanical drives which are not yet supported. I eventually found a way to make them work using the Ticker-library. Attached is the example sketch together with some code that shows how this is done using software PWM. Usage is identical to the Arduino library. It is very simple and I apologize for that but the original library is far beyond my C++ skills. Having said that this code works well. What I tried:
* one and two servos at different pins / speeds
* servo driven via WLAN
Both seemed to work fine with no jitter. Notice though that every servo blocks roughly 10% of the CPU time.
You do not have the required permissions to view the files attached to this post.
User avatar
By RichardS
#13463 Looks nice, does delay() really block? though IGRR had some tricks in there! :-)

Richard.
User avatar
By penatenjoe
#13465 The documentation on github says "The delayMicroseconds function, on the other hand, does not yield to other tasks, so using it for delays more than 20 milliseconds is not recommended." I'm using delayMicroseconds for creating the pulse for the servo which is 1-2 msec long.
Delay (or here Ticker) does allow for the execution of other tasks.