How to create a Acceleration ramp

Hi, everyone, I need to create a acceleration ramp for a DC motor of 150w for moving one prototype cap, had a power side controller, I use 2 mosfets with one mosfet driver, to control the negative pole of dc motor with the PWM of arduino.

Now I want only push one button and the motor had a smoothly acceleration.

Thanks to everyone that can help me

Did you try google ?

http://www.dummies.com/how-to/content/how-to-change-the-speed-of-a-dc-motor-with-the-ard.html

You have to at least make an effort here. Ask a question and we'll answer it. Don't ask us to write your sketch for you . We're not going to do your homework for you. Pick a place to start and start researching it. There's hundreds of tutorial examples out there for accelerating dc motors or pushing buttons. If you can't be bothered to do any of the research then neither can we.

Hi again, ok I have develop this code:

//#include <Servo.h>
//Servo myServo;
const int switchPin = 2; // the number of the switch pin
const int motorPin =  5; // the number of the motor pin

int switchState = 0;  // variable for reading the switch's status

void setup() {
  // initialize the motor pin as an output:
  pinMode(motorPin, OUTPUT);      
  // initialize the switch pin as an input:
  pinMode(switchPin, INPUT);   
//  myServo.attach(10);  
}

void loop(){
  // read the state of the switch value:
  switchState = digitalRead(switchPin);

 if (switchState == LOW) {
   digitalWrite(motorPin, LOW);
   delay(30);
  }
  
 if (switchState == HIGH) {  
//    myServo.write(90);   
//    delay(2000);    
    for(int motorValue = 0 ; motorValue <= 255; motorValue +=1){
    analogWrite(motorPin, motorValue); 
    delay(30);
//    switchState = analogRead(2);
//    if (switchState = 0);
//    break;
     while(analogRead(motorValue) > 10 )
     {
       if(digitalRead(switchPin) == LOW)
       {
         break;
        }
      }
    }
  } 
}

Finally I had the acceleration ramp, but when I want to stop accelerate motor, it doesn’t stop until it reach max rpm (255 of PWM)
i insert the “break” but it doesn’t work, and I don’t know, please help me!!!

thanks

rumisic: Hi again, ok I have develop this code:

I can't make sense of that code - it is nothing like what I would expect to solve your problem.

I suggest you write a bit of code designed to be run at regular intervals, which checks the switch state and sets the motor speed accordingly. The code would need to:

Test whether the switch input was high or low.

If low, stop the motor.

Otherwise, check whether the motor was at the desired target speed and alter the speed if necessary.

This would be an ideal candidate to be implemented as a function. You will need to arrange for this function to be called at regular intervals. You could just call delay() to make your sketch stop after each call, but it would be better to use the technique demonstrated in Blink Without Delay to call it at regular intervals - this would leave your sketch free to do other things independently.