Timers on the ArduinoI contacted David Mellis of the Arduino development team and learned that the library makes use of all three timers on the ATMega168. * Timer0 (System timing, PWM 5 and 6) Used to keep track of the time the program has been running. The millis() function to return the number of milliseconds since the program started using a global incremented in the timer 0 ISR. Timer 0 is also used for PWM outputs on digital pins 5 and 6. * Timer1 (PWM 9 and 10) Used to drive PWM outputs for digital pins 9 and 10. * Timer2 (PWM 3 and 11) Used to drive PWM outputs for digital pins 3 and 11.
digitalWrite(soundPin, HIGH);delayMicroseconds(period/2);digitalWrite(soundPin, LOW);delayMicroseconds(period/2);