Hi!!! How can i generate something like this
||| ||| ||| |||
f N
F
where i can change f, F and N (numbers of pulses) using Arduino Nano. I would be very grateful if anyone can give me an idea to start
Hi!!! How can i generate something like this
||| ||| ||| |||
f N
F
where i can change f, F and N (numbers of pulses) using Arduino Nano. I would be very grateful if anyone can give me an idea to start
What is the maximum for f and F? In frequency or time, doesn't mater, just be consistent with units.
The maximum and the minimum is the one that allows me the arduino Nano
If it was me I'd start with something resembling the shiftOut() function and either add delays or timers to allow you to customise the frequency.
Ok. Thank you!!!
One way to simply generate square waves is with tone(). https://www.arduino.cc/en/Reference/Tone
You can specify the duration of the pulse trains. You can also use tone() and noTone() create a pattern with a millis() timer using "blink with delay" methods.
If you don't want to use time to control the pulses, but want to actually count a number of pulses, you can run the tone output to an interrupt pin and use standard pulse counting methods.
If you need bursts of pulses which are not square wave but have unequal on/off times, you can turn analogWrite() on and off. To vary the frequency with analogWrite() you will need to get into the timers.
In general, for the most control over what you want to do, you will have to get deep into the hardware timers of the processor. A good reference is Nick Gammons tutorial https://www.gammon.com.au/forum/?id=11504
The data sheet for the ATmega 328 will also be helpful.