Created
January 2, 2015 17:29
-
-
Save elentok/5d900904667ad9055152 to your computer and use it in GitHub Desktop.
Arduino motor shield example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "AFMotor.h"; | |
AF_DCMotor motor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm | |
void setup() { | |
Serial.begin(9600); // set up Serial library at 9600 bps | |
Serial.println("Motor test!"); | |
motor.setSpeed(200); // set the speed to 200/255 | |
} | |
void loop() { | |
Serial.print("tick"); | |
motor.run(FORWARD); // turn it on going forward | |
delay(1000); | |
Serial.print("tock"); | |
motor.run(BACKWARD); // the other way | |
delay(1000); | |
Serial.print("tack"); | |
motor.run(RELEASE); // stopped | |
delay(1000); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment