Hi, I have an I2C display OLED, and I just combined the code with the servo, and now the servo moved but it's like It has a long delay time before the next action is made, the screen is the same. Both the screen and servo feel like they only do one action and don't loop.
, could anyone help me check? I'm not pretty sure where the problem is.
i did try to change the value smaller, and it did work for a while, but then the new problem is the screen is not working, when i tried and found that if i just change the last 15 seconds value, then it's the same, so i change all of them, and the servo is good, but the screen now really make me crazy
If you have a ESP32 the matter could be solved by using the OS, freeRTOS.
A state machine and delay using millis() are 2 tools that will solve the responsiveness issue. A search on this site will lead you to Finite State Machine and millis().
What is the “it” you don’t have?
That was a link to tell you how to solve your problem.
You combined your code incorrectly for the code you have. Because the displays seem to need a lot of time between accessing and the servo code is disrupted by long delays you have to convert your code into a state machine. This is where you split your code into two tasks and write a function for each. All the delays need to be removed and any for loops unrolled or replaced by code that just does one iteration of the loop and then returns.
It is not hard if you follow the link and look at the blink without delay example in the IDE.