I'm trying to make the piezo speaker play a sound of certain frequency. However, although I think the code is fine, the sound plays with a frequency between 130 ~160 only, and the frequency actually drops when it should be going up.
The code is as below:
digitalWrite(buzzer, LOW); delayMicroseconds(1000000 / frequency); digitalWrite(buzzer, HIGH); delayMicroseconds(1);
What could be the problem?