making an LFO - "delay" in script?

Discuss Lemur and share techniques.
Post Reply
Dark Arps
Newbie
Posts: 9
Joined: 07 Jun 2013 04:15

making an LFO - "delay" in script?

Post by Dark Arps »

Hi all, first post here :)

I want to generate a crude pulse wave LFO out of the x variable of say, a fader. I'd like to be able to create a script local to that fader that does something like:

void loop() {
Fader.x=1;
delay(Rate.x); // delay time in milliseconds
Fader.x=0;
delay(Rate1.x); // pulse width control
}

this is basically what I know from programming Arduinos, so it's Processing, like C. I think a for loop might be the ticket but I dont know how to do something like this in the Arduino scripting language yet.

My coding abilities are pretty poor so I appreciate if the above attempt doesn't make a lot of sense in places but hopefully you'll get the idea: I want a fader to output 0, then 1, then 0, then 1, and so on, and I want to be able to control the time between switching on and off.

And another question to do with this. I know that I can generate a sine LFO shape with:

Fader.x=sin(time*2)*0.5+0.5;

and if I sub (time*2) for (time*x) I can change the speed of the LFO. But every time I do this, the oscillation restarts instead of smoothly speeding up to the new value with the x variable ramping up to the new value based on the increased speed. How would I get around this?
Post Reply