Trying to control gate (servo) speed

the instruction to change servo from 90 to 180 degrees does so with appropriate delay as instructed, the instruction to reverse the position from 180 to 90 degrees does not provide the requested delay, what must be changed?

void crossingflashing1(int valA1, int valA2) {
digitalWrite(Flash, HIGH);//turns on flasher board
for (pos = 90; pos <= 180; pos += 1) //the servo goes from 90 to 180 degreesin steps of 1 degree
{
myservo.write(pos);//controls the servo
delay(50);
crossingState = ST_ON1;
}
}

void crossingflashing4(int valA1, int valA2) {
digitalWrite(Flash, HIGH); // keeps the flasher on
delay(1000); //1 second delay
flashcount++;//adds 1 to the flashcount
if (valA1 > 200 || valA2 > 200) {
flashcount = 0;
crossingState = ST_FLASHING3;
}
else if (flashcount > 120) {
{
for (pos = 180; pos >= 90; pos -= 1) // goes from 180 to 90 in increments of 1 degree
myservo.write(pos);
delay(50);
}
crossingState = ST_OFF;
}
}

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

ctrl did nothing in the sketch, the complete code wont copy here

You're missing a pair of these {} after your for loop.

Please remember to use code tags when posting code

@Milwrick, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the IDE 1.x category.

Please explain why it will not copy here? What happens? Does your post exceed 120000 (I think that that is the limit) characters? If the full code is indeed too big, you have two options:

  1. Attach it.
  2. Trim it down to the minimum that exhibits the unwanted behaviour.

this code works properly and moves the gate at the correct spped to the horizontal position; void crossingflashing1(int valA1, int valA2) {
digitalWrite(Flash, HIGH);//turns on flasher board
for (pos = 90; pos <= 180; pos += 1) //the servo goes from 90 to 180 degreesin steps of 1 degree
{
myservo.write(pos);//controls the servo
delay(50);
crossingState = ST_ON1;
this code drives the gate back up to verticle at warp speed; void crossingflashing3(int valA1, int valA2) {
digitalWrite(Flash, HIGH); // keeps the flasher on
delay(1000); //1 second delay
flashcount++;//adds 1 to the flashcount
if (valA1 < 200 && valA2 < 200 && flashcount > 5) {
{
for (pos = 180; pos >= 90; pos -= 1) // goes from 180 to 90 in increments of 1 degree
myservo.write(pos);
delay(50);
}
delay(3000);
crossingState = ST_OFF;
}
}

Strange place for a delay.
Please remember to use code tags when posting code

it Seems to work when lowering the gate why not when raising it?

Reformat your code using the auto format tool (it's a mess) - see if you can spot it.

used the Auto Format from the tools menu and same response from the gate when raising. also cannot see any changes to code.

Look at your two for loops - can you see a difference?

(If you change code, it's a good idea to repost it. In code tags)

Also, see reply #7

I cannot see a difference between the two , that's what is so puzzling to me

See also reply #4
(I thought this one looked familiar)

I looked after recieving that comment but still cannot see a difference

im obviously missing something! this is my first try at using Arduino and seems to be a steep learning curve for someone with no coding experience

Post your reformatted code.
In code tags.

You're missing a pair of these {}, as I wrote earlier.

Coding Tags????

No, "code tags"

some how the Delay of 50 is not being recognized in the raise code but IS is the lower code.

Because you're missing a pair of these {}