# How to generate around 3V TTL clock with 9.6 kHz, 50% duty cycle?

Hi All,

I am new in Arduino. I would like to generate around 3V TTL clock with 9.6 kHz, 50% duty cycle. Does anyone know how to do it? Or just give me some ideas to generate this signal. Thanks so much!

Tim

~3V TTL Analog signal

A what?

AWOL:
A what?

Thanks for the reply, just edited.

Tim

generate a 5Volt one and use a voltage divider to make it 3V

then run a loop like this?

``````d = 1000000 / 9600 / 2; // or something like this, they might even differ slightly
while(1)
{
digitalWrite(pin, HIGH);
delayMicroseconds(d);
digitalWrite(pin, LOW);
delayMicroseconds(d);
}
``````

another way is to use a timer interrupt an switch the status of the pin in the ISR

robtillaart: generate a 5Volt one and use a voltage divider to make it 3V

then run a loop like this?

``````d = 1000000 / 9600 / 2; // or something like this, they might even differ slightly
while(1)
{
digitalWrite(pin, HIGH);
delayMicroseconds(d);
digitalWrite(pin, LOW);
delayMicroseconds(d);
}
``````

Thanks Rob, I just tried the first method as you mentioned. I connected the signal in Oscilloscope, but the ~9kHz signal is shaking by a small range in x-axis. I also tried lower frequency, the signal looks very stable.

For the second method, do you have recommended reference?

Tim

ztw317: I am new in Arduino. I would like to generate around 3V TTL clock with 9.6 kHz, 50% duty cycle. Does anyone know how to do it? Or just give me some ideas to generate this signal. Thanks so much!

The easiest way to generate 50% duty cycle signals in the audible frequency range is the Arduino tone function: http://www.arduino.cc/en/pmwiki.php?n=Reference/Tone