KEY TAKE AWAY POINTS:
Frequency(f) is measured in Hertz(Hz), is defined as how many times this periodic event happens per second
Period(T) is how long time for one periodic event
T= 1/f
f=1/T
START A BIT > Knowledge Base > This page
1 s = 1000 ms = 1000000 us
1 ms = 1000 us
Alternating LED ON and OFF to generate a blinking result
A “Blinking Event” has
half period as ON,
half period as OFF
The main challenge is to calculate the right period from the input Hz
Alternating digital output HIGH/LOW to generate vibration driving buzzer playing a specific pitch
A “Vibration Event” has
half period as Voltage ON,
half period as Voltage OFF
The main challenge is to calculate the right period from the input Hz
void loop() {
// Alternate digital output HIGH/LOW to generate vibration
digitalWrite(BUZZ_PIN, HIGH);
delayMicroseconds(half_period_us);
digitalWrite(BUZZ_PIN, LOW);
delayMicroseconds(half_period_us);
}
basic.pause(1 / blinking_hz / 2 * 1000)
basic.pause(1 / blinking_hz / 2 * 1000)
basic.pause(1 / blinking_hz * 1000)
basic.pause(1 / blinking_hz / 2
Divided by 0 when blinking_hz becomes 0
This is "illegal/invalid" operation in math or computer, just don't do it!
"Hertz" in Wikipedia: It is used only in the case of periodic events.
Some saying: Zero hertz means zero cycles per second, which means nothing is changing.
Some saying: Zero Hertz is a frequency that represents a complete absence of periodic oscillation. It means that there is no repeating pattern in the waveform and it is just a constant value.
Let's say:
We know "0 Hz" is confusing definition, the meaning might differs for specific cases (sound, wave, light, electrical signals, etc.)
We allow blinking_hz to be 0
We agree that "0 Hz" implies "no blinking at all", i.e. the LED dot is ON permanently.
because it make natural sense for our use case, when blinking_hz becomes lower and lower, we just feel the blinking becomes slower and slower, then we reasonably want it to be constantly ON if blinking_hz becomes even lower near to, or as, 0