Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/adafruit/Adafruit-Motor-Shield-library.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examplesketch/MotorTest/MotorTest.pde')
-rw-r--r--examplesketch/MotorTest/MotorTest.pde52
1 files changed, 52 insertions, 0 deletions
diff --git a/examplesketch/MotorTest/MotorTest.pde b/examplesketch/MotorTest/MotorTest.pde
new file mode 100644
index 0000000..46eccc1
--- /dev/null
+++ b/examplesketch/MotorTest/MotorTest.pde
@@ -0,0 +1,52 @@
+// Adafruit Motor shield library
+// copyright Adafruit Industries LLC, 2009
+// this code is public domain, enjoy!
+
+#include <AFMotor.h>
+
+AF_DCMotor motor(4);
+
+void setup() {
+ Serial.begin(9600); // set up Serial library at 9600 bps
+ Serial.println("Motor test!");
+
+ // turn on motor
+ motor.setSpeed(200);
+
+ motor.run(RELEASE);
+}
+
+void loop() {
+ uint8_t i;
+
+ Serial.print("tick");
+
+ motor.run(FORWARD);
+ for (i=0; i<255; i++) {
+ motor.setSpeed(i);
+ delay(10);
+ }
+
+ for (i=255; i!=0; i--) {
+ motor.setSpeed(i);
+ delay(10);
+ }
+
+ Serial.print("tock");
+
+ motor.run(BACKWARD);
+ for (i=0; i<255; i++) {
+ motor.setSpeed(i);
+ delay(10);
+ }
+
+ for (i=255; i!=0; i--) {
+ motor.setSpeed(i);
+ delay(10);
+ }
+
+
+ Serial.print("tech");
+ motor.run(RELEASE);
+ delay(1000);
+}