1 LED 2 pots

Hi Arduino newb here.
Can anyone tell me if its possible to have 1 LED controlled by 2 pots, so that one pot controls the blink rate (Speed) and another that controls the LED intensity (Depth). I have been able to do the first easy enough by following the helpfull example titled AnalogueInput - http://arduino.cc/en/Tutorial/AnalogInput

Also on my breadboard I can just add the 2nd pot and bleed current off the LED to ground.

But how would one do this with the Arduino alone. Also read somewhere else on this forum that there are stages of brightness in an LED - can someone explain that a bit more?? And possibly how I could use that info in my sketch to really fine tune the depth/intensity pot?

I am using the Arduino in place of a 555 timer chip in an very simple analogue tremolo effects pedal for guitar that includes an homemade optocoupler (LDR and LED). Basically, I have a passive side on my beadboard: input jack>LDR>output jack - on the other side of the breadboard its active, which has the +-power wires, and a wire from pin (9) >220R resistor>LED. When I put cap over the board (as in hat not capacitor lol ;)) the blinking LED/LDR allows the guitar signal to pass through with fairly pleasing tremolo sound.

I have really only had the board a couple of days and no code experience and am doing this as a learning excercise. Any info about how to approach coding this properly or where to find that info on the Arduino site - would be much appreciated.
cheers
Steve

Put your LED on one of the PWM pins and use analogWrite to control the intensity of the ON time.
Very simplest code could be something like:

void loop ()
{
  analogWrite (LEDpin, analogRead (potPin0) / 4);
  delay (analogRead (potPin1));
  analogWrite (LEDpin, 0);
  delay (analogRead (potPin1));
}

AWOL:
Put your LED on one of the PWM pins and use analogWrite to control the intensity of the ON time.
Very simplest code could be something like:

void loop ()

{
 analogWrite (LEDpin, analogRead (potPin0) / 4);
 delay (analogRead (potPin1));
 analogWrite (LEDpin, 0);
 delay (analogRead (potPin1));
}

Ok thanks very much

so my basic code now looks like this and works perfectly in my Trem-O-duino pedal. :slight_smile:

int potPin1 = A1;
int potPin0 = A0;
int ledPin = 9; 
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
}


void loop ()
{
  analogWrite (ledPin, analogRead (potPin0) / 4);
  delay (analogRead (potPin1));
  analogWrite (ledPin, 0);
  delay (analogRead (potPin1));
}

Hoping you can explain what the "4" represents??

thanks very much for this. I'm loving Arduino - I've got lot of reading to do...

analogRead (potPin0) is reading your potPin0 and will return a value between 0 and 1023.
analogWrite is expecting a value between 0 and 255.
So the / 4 is there to dived (by 4) the value returned by analogRead so it is usable by analogWrite.

Read up on it at this page: Arduino - Home

Also, there's no need to set the pinMode of a PWM pin if that's what you're going to use it for - the analogWrite takes care of it.