I'm trying to control the speed of a DC motor using PWM. Here is my code so far:
int motor = 9;
int fadeValue = 5;
void setup() {
pinMode(motor, OUTPUT);
}
void loop() {
for (int fadeValue = 5 ; fadeValue <= 245; fadeValue += 10) {
analogWrite(motor, fadeValue);
delay(100);
if (fadeValue==245) {
fadeValue=255;
break;
}
}
I want the motor to slowly increase it speed then stay high. However, the loop keep repeating.
Thanks in advance guys.
loop()
call: github.com/arduino/Arduino/blob/1.8.1/hardware/arduino/avr/…