speed control using cytron algorithm code example
Example: speed control using cytron algorithm
void loop(){
int pwm_value=0;
lcd.setCursor(0,0);
digitalWrite(dir,HIGH); // set DIR pin HIGH or LOW
for(pwm_value=0;pwm_value<256;pwm_value++){
analogWrite(pwm,pwm_value); //increase PWM in every 0.1 sec
delay(100);
lcd.clear(); //display status of motor on LCD
lcd.setCursor(0,0);
lcd.print("PWM:");
lcd.print(pwm_value);
lcd.setCursor(0,1);
lcd.print("DIR:");
lcd.print(digitalRead(dir));
}
while(1) continue; //continue,terminate loop;
}