variating an ouput over time

hi there
im trying to alter a pwm output over a period of time which can be adjusted by a potentiometer from 5mins to 25mins and also another potentiometer to adjust the maximum position it will go up to any ideas of how to do this or any examples anyones got ?

What do you want to happen when the end of the 5-to-25-minute time interval is over?

static unsigned long startTime = 0;

int maxBrightness = map(analogRead(brightnessPot), 0, 1023, 0 255);
int maxSeconds = map(analogRead(timePot),0, 1023, 5*60, 25*60);

int elapsedSeconds = (millis() - startTime) / 1000;

// Assuming you want to start over at dark when the time limit is up
if (elapsedSeconds >= maxSeconds) {
    startTime = millis();
    elapsedSeconds = 0;
    }

analogWrite(outputPin, map(elapsedSeconds, 0, maxSeconds, 0, maxBrightness));

What do you want to happen when the end of the 5-to-25-minute time interval is over?

nothing just want it to variate an output over a period of time when a switch go's high

Joes:

What do you want to happen when the end of the 5-to-25-minute time interval is over?

nothing just want it to variate an output over a period of time when a switch go's high

"Variate" isn't a real word. Do you mean "vary"? If so, how do you want it to vary - just a linear change in the duty cycle starting at zero and ending at the maximum defined by your pot? Is it possible that either of the pots will be adjusted during this timed processing? You mentioned a switch - do you need to deal with the switch going low or high after it has triggered this process? Do you want to respond to any further changes to the switch state during the time processing? How about after it has completed?

just a linear change in the duty cycle starting at zero and ending at the maximum defined by your pot?

yes and to go the other way when the switch is in the opposite direction

Is it possible that either of the pots will be adjusted during this timed processing?

no

You mentioned a switch - do you need to deal with the switch going low or high after it has triggered this process? Do you want to respond to any further changes to the switch state during the time processing? How about after it has completed?

i was using the switch to trigger the process for example when the switch goes high it will slowly increase the pin over the duration the one pot is set to and to the maximum point the other pot is set to when that point has reached it will stay there until the switch goes low and then it will wind back down to 0 over the period of time the pot is set at

Joes:
i was using the switch to trigger the process for example when the switch goes high it will slowly increase the pin over the duration the one pot is set to and to the maximum point the other pot is set to when that point has reached it will stay there until the switch goes low and then it will wind back down to 0 over the period of time the pot is set at

OK, I think I understand what you want now.

You need to read the switch state repeatedly until it changes. When it changes, read the analog pots to establish the timing and maximum level settings.

Hard-code the relationship between the timing pot and the time interval between adjusting the output value.

Each time the time interval passes, adjust the output value. The new output value will be determined by multiplying the proportion of the time that has passed, and the maximum level. This will give you a duty cycle which you output by doing an analog write.

For what it's worth, I suggest you continue to monitor the switch and reverse the direction if the switch is changed during this process - just because systems that lock up and won't allow you to interrupt what they're doing irritate me.

yes ok
so how do we do that then?

Joes:
yes ok
so how do we do that then?

Well, you take each of the sentences above and implement the corresponding behaviour in your code.

Do you know how to read the state of a switch? Do you know how to do it repeatedly? Do you know how to record the previous state and detect when the current state is different to the previous state? It's not hard, and you don't need to do the whole thing in one go, just start from the basics and work up. Make sure you test each part and get it working as you want before you move on to the next part. A sketch that prints a message each tiome the switch changes would be a good start. Then add code to read the analog inputs and print those values at the same time. And so on.

Do you know how to read the state of a switch?

yes

Do you know how to do it repeatedly? Do you know how to record the previous state and detect when the current state is different to the previous state?

no

How would you (not programming) determine if a light had been switched on, if you had no long term memory, but you did have a sheet of paper, a pencil and an eraser?

forget it, as by the time ive started writing it down i have already forgotten what i was going to write lol

void loop()
   {
   static unsigned long startTime = 0;
   static boolean switchState = LOW;

   if (digitalRead(switchPin) != switchState) {
      startTime = millis();
      switchState = digitalRead(switchPin);
   }

   int maxBrightness = map(analogRead(brightnessPot), 0, 1023, 0 255);
   int maxSeconds = map(analogRead(timePot),0, 1023, 5*60, 25*60);
   int elapsedSeconds = (millis() - startTime) / 1000;

   if (switchState && elapsedSeconds < maxSeconds) {
      // Getting brighter
      analogWrite(outputPin, map(elapsedSeconds, 0, maxSeconds, 0, maxBrightness));
   }

   if (!switchState && elapsedSeconds < maxSeconds) {
     // Getting dimmer
      analogWrite(outputPin, map(elapsedSeconds, 0, maxSeconds, maxBrightness, 0));
   }
}

Joes:
no

Are you serious about completing this project, or just speculating wildly about something in the hope that somebody might write for you?

thanks johnwasser for that can you explain what is going on in it?

Joes:
thanks johnwasser for that can you explain what is going on in it?

You'll learn more if you try to understand it yourself.

If you don't want to learn, I will write the complete sketch for $50.