For loop not working

Hello,

This is (I hope) a very simple problem: I want to send three pulses at different frequencies upon pressing a defined key on my computer, and I would like these 3 different pulses to be sent 10 times in a row.
Here is the code I used:

#include <bitlash.h>

void setup() {

pinMode(13, OUTPUT);
Serial.begin(9600);

}

void loop(){

  int var = 0;
  int var2 = 0;
  int var3 = 0;
  int var4 = 0;
  int var5 = 0;
  int var6 = 0;
  int var7 = 0;

 
  if (Serial.available() > 0){ 
   if (Serial.peek() == 'm'){
    Serial.read(); 
    for(int i = 0; i < 10; i++) {
      
      while(var < 20) {
        digitalWrite(13, HIGH);
        delay(1);
        digitalWrite(13, LOW);
        delay(99);
        var++;
      }
    
      delay(1000);
    
      while(var2 < 60) {
        digitalWrite(13, HIGH);
        delay(1);
        digitalWrite(13, LOW);
        delay(1940/60);
        var2++;
      }
    
      delay(1000);
  
      while(var3 < 100) {
        digitalWrite(13, HIGH);
        delay(1);
        digitalWrite(13, LOW);
        delay(19);
        var3++;    
      }
  
      delay(1000);
         
    }
  }
 }
  else {
    digitalWrite(13, LOW);
    }

}

When I press the assigned key, it does send the 3 pulses but only one time, as if ignoring my for loop. Any suggestions on what might be causing the problem? I also tried using a while, to no success.
I am new to programming so I know my code is not the most elegant, but I can’t figure out why this won’t work. Any help would be much appreciated.

Thanks in advance!

Once var exceeds 20, where do you reset it? Add a Serial.print() statement to the for loop. You'll see that the loop does indeed execute 10 times, but the 2nd, 3rd, etc. times, there is nothing for it to do.

Thank you very much, for some reason I thought they would be resetted at the end of the for loop. Resetted them, works perfectly!

Have a nice day

delay(1940/60);

1940/60 =32.33333333333333333333
delay will only use the int value (32), the remainder (0.3333333333333333333) will be ignored.
For more accuracy use delayMicroseconds(32333);

Henry_Best:

delay(1940/60);

1940/60 =32.33333333333333333333
delay will only use the int value (32), the remainder (0.3333333333333333333) will be ignored.

1940/60 = 32 (it's integer math, after all).

christop:
1940/60 = 32 (it's integer math, after all).

Using 'real world' maths, 1940/60 =32.33333333333333333333.
Integer maths introduces an error that the OP may not have been aware of.
That is what I was pointing out.