PWM, different analog values?

Hey guys, i have a small problem, i need a pwm but my analog values are not a 0-5V, my lowest value are 2 volts and highest is 3 volts.For 2 volts i must have a 0% duty cycle, for 3 volts full 100% duty cycle, i don't have any idea how to make it?

Hi, try this:

PaulRB:
Hi, try this:

Hi Paul, but i have opposite problem, voltage which control arduino is between 2 and 3 volts , for 2 volts on a analog in must have a 0% duty cycle for 3 volts on a analog in must be 100% duty cycle. For example this work perfekt but vrom 0 to 1 volts

int ledPin = 3;      // LED connected to digital pin 9

int analogPin = 0;   // potentiometer connected to analog pin 3

int val = 0;         // variable to store the read value

void setup()

{

  pinMode(ledPin, OUTPUT);   // sets the pin as output

}

void loop()

{

  val = analogRead(analogPin) / 4 ;   // read the input pin
  {
if (val < 50) 

analogWrite (ledPin, LOW); 
}

if (val > 55) 
analogWrite (ledPin,  (val / 2)  ); 

}

I'm sorry but I am finding your question, and your sketch very difficult to understand.

can I suggest you take a look at the map () function.

Paul