void setup(){
pinMode(9,OUTPUT); //initialize the 9 pin as output
pinMode(10,OUTPUT); //initialize the 9 pin as output
}
void loop(){
analogWrite(9,255); // Turn the motor on clockwise, full speed (255)
analogWrite(10,0); //
delay(1000); //wait for a second
analogWrite(9,0); //Turn the motor on counter clockwise, full speed (255)
analogWrite(10,255); //
delay(1000); //wait for a second
}
Challenge: Use two buttons to control the motor. If you push one button it goes clockwise, if you push the other button it goes counter clockwise.