Program
int value = 0; // a variable that contains the value to get analog input terminal
int motor = 10; // motor connected to PIN 10
void setup(){ // Not necessary
void loop(){
for(value = 0; value <= 255; value +=5){
//generates a ramp of voltage from 0 to 255, i.e. from 0 to 5v
analogWrite (motor, value);
delay (30); // wait 30 ms to make the effect visible
}
for(value = 255; value >=0; value-=5){
// a down ramp from 255 to 0 voltage is generated that is 5 to 0v
analogWrite (motor, value);
delay (30);
}
}
Installation variant: using a potentiometer as speed control.
To control the speed to our liking, i.e. using a potentiometer which is placed in
one of the analog inputs and based on the value that is read at the input, so the
motor rotates more or less fast.
21
21