I'm making a kind of automatic feeder. So when it's time to eat, the servo will open (180°) the lid of the feed container and the feed will be forwarded to the dc motor which will be a feed launcher. When the dc motor reaches its peak speed (let's say 150), the servo will close (0°) and the dc motor will slowly decrease its speed. I hope my language is understandable
my code won't open the servo because there is no delay() for the servo to open. if i use delay there. the servo will be closed immediately before the dc motor rotates
your words aren't matching what the code appears to do
most servos take very little time (0.1 sec) to move. do you believe this is correct?
I added prints to your code. The output shows that the motor shouldn't reach a speed of 150 for about 10 sec (39.44.067 - 39.34.067) after the servo moves to 180
shouldn't the servo have moved to 180 within 0.1 sec of starting the motor?
06:39:34.067 -> servo 180
06:39:34.067 -> motor at speed 0
06:39:44.251 -> motor at speed 150
06:39:45.281 -> servo 0
06:39:45.281 -> motor at speed 150
06:39:55.477 -> motor at speed 0
I expect servo and DC motor to run together. but I don't know what the correct code is. servo opens when DC motor is running, and closes when DC motor stops
The code I made at the beginning did not work properly. Because at the beginning it was initialized in position 0° (int pos = 0;). So if there is only the command myservo.write (180); without the delay(); function, it will not work. Sorry if I misunderstood
Because, my purpose of using a DC motor for the feed launcher is to spread the feed evenly. From the nearest to the furthest side of the pond, all are covered. I hope you can imagine it.
I don't use a load cell to measure the weight. I just use time calculations. So if the servo and DC motor don't move together, it's feared that the measurements won't be correct.
I have tried it many times. With or without delay, the result is as I explained before. Servo needs delay, but delay will delay all programs. So servo and DC motor cannot work together