while loop does not stop / 7 segment with 4026


i have a weird problem. i hooked up a 4026 with a 7 segment and want to use arduino as impule driver. everything works actually, the 7 segment counts up from 0 to 9 with impulses given from the arduino but it wont stop. i want my arduino pulse 6 times and then stop?
im a bit stuck here. i dont know what i am doing wrong?

int var1;
int var2;

void setup() {                
  pinMode(13, OUTPUT);  


void loop() {
   var1 = 0;
   var2 = 6; 

   while(var1 < var2){

       digitalWrite(13, HIGH);   // set the LED on
       delay(100);              // wait for a second
       digitalWrite(13, LOW);    // set the LED off
       delay(100);              // wait for a second

im just playing around but the idea is later to have var2 inside a sensor or something
any sugestions? it just loops thru without stopping


No it does stop. BUT it is in the loop() function so when it finishes the loop() starts it off again. Put a print statement outside the loop and see it does finish, then start again.

move these to setup, outside of void loop:

var1 = 0; var2 = 6;

otherwise, it does the High/Low writes, goes to the start of loop, resets them, and starts the High/Low writes again.