How to make program stop after 10 iterations?

Hi, so I have a program that I am trying to create where I have an external LED connected to the board as well as a wire we use as a switch, the switch is supposed to start connected to the ground and another port, when I pull the wire out, the external LED should turn on and that should count as 1 iteration, I am supposed to make the program run for 10 iterations (pull out = 1, put back = 1) then stop working and have the internal LED blink when I have reached 10.

I am just not sure how to get the program to stop after the 10th iteration, I have tried to use a while loop but i'm not sure it's doing what its supposed to do since it doesn't work, I would appreciate any help with this, and I will post what code I have if needed, thank you!

Please read and follow the directions in the "How to use this forum" post. Post the code, using code tags.

You should learn to use a switch or pushbutton for input. "Pulling a wire out" is a terrible practice, leading to destruction of equipment, and is an extremely unreliable way of providing input to a computer.

jremington:
"Pulling a wire out" is a terrible practice, leading to destruction of equipment, and is an extremely unreliable way of providing input to a computer.

Yeah, but it's pretty common in disarm-the-bomb setups, isn't it?

I think they usually have to cut the red wire, not the blue one, using wire cutters.

Only a screenwriter would make a bomb that started to count if it was being disarmed..

But you actually want to change the flash from one pin to another..

So have a variable for the PIN number, and a variable for a counter and a if statement that when the counter is over 10 it changes the pin variable to the internal.

jremington:
I think they usually have to cut the red wire, not the blue one, using wire cutters.

Which red?

.

Always show us your ‘current’ complete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0

You could combine these two examples:

And you could get a perfect solution for the task.

TommyGun4:
I will post what code I have if needed, thank you!

It is essential to see your code.

...R