frequency to period question

Hey all,

ok, I know that the frequency of a note is cycles/second and to implement that with the Arduino (turning a speaker on/off a certain number of times every second) you need to do a:

digitalWrite(notePin, HIGH);
delay x;
digitalWrite(notePin, LOW);
delay x;

repeat ad nauseum where x is half of the period, unless you're doing some fun stuff with the pulse width and don't want a 50% duty cycle... but I get ahead of myself...

Now, in theory, I can do the calculations to get the period. and I can convert it to microseconds so it's easier to work with in the program and divide by two to get how much on and how much off.

I'm not getting the same numbers as used in the Arduino Synth page on the playground Arduino Playground - PbSynthCode

here's the equations I'm using:
period = 1/frequency
period in microseconds = period * 1000000
time on = time off = period in microseconds / 2

Am I doing something wrong or missing something?

If you use Arduino 0018, it has a tone function that makes this stuff very easy, you just tell it which pin, the frequency and the duration.

http://arduino.cc/en/Reference/Tone

Aye, tone is a nice idea, but is there a way to do PWM with the tone function?