Turning a 360 degree servo while lighting an LED

Hello, I'm trying to code a project using Uno or Nano to turn a continuous rotation FS90R servo in 90 degree increments and stop for 4 seconds in between turns. I also need and LED to light while the servo is stopped and turn off during the movements. Any help would be greatly appreciated. Thanks in advance!!

Attach the code, using code tags </>, You have made soo faar.

<#include <Servo.h>
int ledPin = 13; // LED connected to digital pin 13

//positioning a continuous rotation servo
//using a delay to poistion the motor
#include <Servo.h>
Servo myServo;

void setup() {
myServo.writeMicroseconds(1500); // Stop
pinMode(ledPin, OUTPUT); // sets the digital pin as output

void loop() {
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
myServo.write(1600); //C-Clockwise
myServo.write(1500); //Stop
} >

Looks possible. What is worong?
Look for “code tags”, the symbos </>, for attaching code.
The wiring diagram might be useful.

The issue I'm having is the delay. It will move the servo then after the 4 second delay it will light the LED. I'm also having issues with inconsistency in the 90 degree moves. I've tried to nail down the timing but some moves go 90 degrees while others go 100 and others go 80. I need accuracy in the movements. I saw an article on using millis instead of delays but it's a little more involved than I'm capable of.

Ok. You use Servo.write(1500) and Servo.write(1600). Is that good? Why not the same number, 1500 or 1600? I don't know the servo library.
After the 4000 mS delay the sketch uses 1 + 1 second for the LED. Totally I sum it up to 4000 + 1000 + 1000 + 267.5 mS for one cycle. Is that okey?

Servo.write(1600) is to move counter clockwise and at that speed.

I didn't adjust the LED timing because the sketch slowed the servo movement so much I realized this isn't going to work as is.

I need the LED to light during the 4000 ms delay of the servo but my understanding is the processor can't issue commands during a delay.

I'm looking for absolute accuracy, in movements and turning the LED on/off instantly when the servo stops/moves. I wonder if a stepper would be better?

Drop the second LED delay(1000). The servo will then start immedeately when the LED goes off.
"delay(xxx)" hangs up the processor for xxx mS. During that hanging nothing useful is done.

Maybe I can cut the servo delay short since the servo won't move while the LED delay is on and then cut the LED delay to move the servo again...I think I'm starting to get it.

Any advice on getting the servo movement more accurate?

I'm looking for absolute accuracy, in movements

You will not achieve it with a continuous rotation servo. Consider using a winch servo designed to rotate 360 (or more) degrees

See it like this:

The processor is performing like this:

Wait for 1000 mS, doing nothing else
Wait for 1000 mS, doing nothing else

Start servo
wait 276.5 mS, doing nothing else
Stop servo
Wait 4000 mS, doing nothing else

Maybe the short delay of 276.5 mS is not enough? Give it ome more time.
And, I never used delays having fractions of mS. Does that work? Use either 276 or 277 mS, or a lot more for testing.

Thank you Railroader!! I'll modify my code and see how close I can get to what I need.

Pay attention to post #9 by UKHeliBob.

You will not achieve it with a continuous rotation servo. Consider using a winch servo designed to rotate 360 (or more) degrees

Thank you!! I will certainly look into that. Do you think a stepper would be accurate?

I am using steppers and they are very accurate. You must not overload them, not call for more torque than they can handle, and You need to accelerate/decellerate within limits. No problem for most tasks.

That might work better then, I'm only turning a 3 inch plastic disc. And I already have the stepper drivers and motors. Maybe I'll give that a go too. Thanks again, very helpful!!!

Yes, setup Your stepper and its driver board. You will like result.

This is my new code and it does exactly what I want now, my next step is…well, stepper motor. Thanks again!!

#include <Servo.h>
int ledPin = 13;                
#include <Servo.h>
Servo myServo;
void setup() { 
  pinMode(ledPin, OUTPUT);     

void loop() { 
digitalWrite(ledPin, HIGH);  
  digitalWrite(ledPin, LOW);   

Make small step changes and verify each step. Making a stepper move a number of steps forward and backward, making sure it does what You want.