/*
 * 
 * Simple (PWM) Low Frequency Oscillator (LFO)
 * 
  Instead of using the square waves to generate oscillations in the (human) audio spectrum (20Hz-20KHz)
  You can use low frequency oscillations as 'control voltage': using the PWM HIGH (+5v) and LOW (0v) to trigger other modules 
  and control their adjustable parameters connected to Analog pins 0,1,2 and 3
  Most LFO's do reach the audible spectrum when oscillating fast enough ofcourse.

        |
   HIGH |       ___      ___
        |      |   |    |   |     50% duty cycle
   LOW  |  ____|   |____|   |     (50% on, 50 off) Determined by delayMicroseconds()
        |
        |____________________
                TIME

 * 
 * 
 * 
 * 
 * 
 */

 
#define SPEAKER_PIN 11 //the output pin

void setup() {
  // set pin 11 as output
  pinMode(SPEAKER_PIN, OUTPUT);
}

void loop() {
 
    digitalWrite( SPEAKER_PIN, LOW ); // 0v to pin 11
    delay( analogRead(A2)*5 ); // wait*10, analogRead gives values between 0-1023, so max wait is 1sec, lets make it ~5sec by multiplying the read value * 5
    digitalWrite( SPEAKER_PIN, HIGH ); // +5v to pin 11
    delay( analogRead(A2)*5 ); // wait*10, analogRead gives values between 0-1023, so max wait is 1sec, lets make it ~5sec by multiplying the read value * 5

}
