I am writing a function
void Sound_Play(int frequency,int millisec)
A part of this function is:
counting=(millisec*frequency/1000); //counting is type int
Serial.println((String)"millisec="+millisec+" frequency="+frequency+" (millisec*frequency/1000)="+(millisec*frequency/1000)+" counting set to="+counting);
But when I call the function with millisec=500 and frequency=220, the result on the Serial Monitor is:
millisec=500 frequency=220 (millisec*frequency/1000)=-21 counting set to=-21
Shouldn't counting should be 110 instead.I tried casting the result to int but in vain. What am I doing wrong and how to correct it? Thanks! Bhuvnesh