I want a function generator. Believe it not I couldn't find it thru Google... U know... Sine, saw, square wave given args of frequency and possibly duty cycle.
I can code one I suppose... Start with sin(millis() / 1/f).. help me a little. It's for a fx to blink LEDs and make sounds.. I want scalability.
Digial circuits can produce square waves. How do you intend to produce other waveforms?
Interesting, I just went to eBay, searched for "function generator" and got 2600 hits. Either your ISP provider is blocking your searches or something is wrong, I tried google and got a lot of them. There are also chips that will do that. Look for a color organ, it connected to your audio and gives you blinks, colors etc. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
No! In c++... It seems STUPID that you can't find code for one even tho the things are produced with electronics.
Code is a lot like babies - you don't find code under the mulberry bush, you have to put in time and effort.
Maybe this hobby isn't for you.
mattlogue:
I want a function generator. Believe it not I couldn't find it thru Google... U know... Sine, saw, square wave given args of frequency and possibly duty cycle.
I can code one I suppose... Start with sin(millis() / 1/f).. help me a little. It's for a fx to blink LEDs and make sounds.. I want scalability.
mattlogue:
No! In c++... It seems STUPID that you can't find code for one even tho the things are produced with electronics.
I am missing something at the heart of all this.
gilshultz:
... There are also chips that will do that. Look for a color organ, it connected to your audio and gives you blinks, colors etc.
'chips' are electronics.
did you mean in software, specifically the C++ version for the Arduino ?
DrDiettrich:
Digial circuits can produce square waves.
There's one
You can use one of the many FADE sketches to make a SINE and have an LED go from off to on to off to on.....
That makes two.
We typically advise that a complete program is made up of smaller pieces.
if you make a list of what you want, my guess is that it already exists, but in pieces and maybe used for something else.
I suppose I could make a fx , say x(freq)start out with micros() % (1M / freq) / freq. That's rampUp. RampDown is 1-rampUp. Square with duty cycling can be derived from applying calculated threshold's to sin(x()). Where I get flummoxed is when I get greedy... I want to use a fx for arg of another and I want them to keep sync. Also, more elementary I suppose, I'd probably want a wrapper fx to arithmetically combine them. Eg: consider fx request for "SOS"Morse code (sq wave 4hz * sq wave at 1/3 hz) + (sq wave 1.5hz * 1-square wave from prior). Sure u can hard-program that in in seconds, but I'm obsessed with scalability. Obsessed.
Should I write it into a class library and instantiate several objects of fxGen()..
Should I set it that each time it's invoked it assigns a slot in array to store the microsecond it started?
You (everybody) can implement that as s/he likes. If you drop the original requirement for sawtooth and sine shapes, everything boils down to toggle an output pin high/low at more or less regular time intervals.