# Making square wave and PWM

Hi all,

I'm a noob user about arduino.
I want to make square wave ranging from 1 Hz to 100 Hz.
I did some research and found out that the function 'tone()' generates square wave from 31 Hz to 65535 Hz for UNO.
Is there any way to generate under 31 Hz? especially I need 10 Hz sqaure wave.

Another restriction is I need square wave from 0V to 2V not over that. Is it possible with just coding it?
If arduino provides negative voltage -0.5V to 1.5V would be perfect.

Also, about PWM, I need periodic PWM signal like 50Hz 3 pulse and rest for 200 msec then 50 Hz 3 pulse and rest for 200 msec ... repeating like that. Can I realize it with just coding it? If possible plz let me know

I want to drive the pulse to gate of MOSFET which cap is about 1.2 pF

Thanks

I would have thought that 1 Hz to 100 Hz is possible with just a software toggle of the output pin and a delay call. A simple voltage divider might help with reducing the output to 2V.

And by varying the delays between pulses, you can get any pulse stream you like

regards

Allan.

dillon1859:
Hi all,

I'm a noob user about arduino.
I want to make square wave ranging from 1 Hz to 100 Hz.
I did some research and found out that the function 'tone()' generates square wave from 31 Hz to 65535 Hz for UNO.
Is there any way to generate under 31 Hz? especially I need 10 Hz sqaure wave.

By hacking (a copy of) the tone() function - remember you have all the sourcecode.

Another restriction is I need square wave from 0V to 2V not over that. Is it possible with just coding it?

No, you need external circuitry.

If arduino provides negative voltage -0.5V to 1.5V would be perfect.

It doesn't - external circuitry again.

Also, about PWM, I need periodic PWM signal like 50Hz 3 pulse and rest for 200 msec then 50 Hz 3 pulse and rest for 200 msec ... repeating like that. Can I realize it with just coding it? If possible plz let me know

Yes you can code this. You could even be clever and use a timer to do most of the work, but its probably
less ambitious to just use millis() and a state-machine.

I want to drive the pulse to gate of MOSFET which cap is about 1.2 pF

That won't be a power MOSFET then! Perhaps you could say which device and what its doing?

Thanks

[/quote]