From 73a59225bc9134a29a91fb1a08e85606f7d2d699 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Mon, 15 Nov 2021 22:45:31 -0500 Subject: [PATCH] Add a demo Arduino file --- ino/demo/demo.ino | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 ino/demo/demo.ino diff --git a/ino/demo/demo.ino b/ino/demo/demo.ino new file mode 100644 index 0000000..d976c87 --- /dev/null +++ b/ino/demo/demo.ino @@ -0,0 +1,65 @@ + +/** + * Prototype + * Arduino Duemilanove + * L298N shield V03 + * + * Pin 13 = motor A or coil A + + * Pin 12 = motor A or coil A – + * Pin 11 = motor B or coil B + + * Pin 10 = motor A or coil A enable + * Pin 9 = motor B or coil B enable + * Pin 8 = motor B or coil B – + **/ + +#define Apos 13 +#define Aneg 12 +#define Aenable 10 + +void setup() { + pinMode(Apos, OUTPUT); + pinMode(Aneg, OUTPUT); + pinMode(Aenable, OUTPUT); +} + +void loop() { + clockwise(); + set_speed(50); + delay(5000); + brake(); + delay(2000); + counter_clockwise(); + set_speed(100); + delay(5000); + brake(); + delay(2000); +} + +//input value from 0 to 255 +void set_speed (int val){ + analogWrite(Aenable, val); +} + +void clockwise(){ + digitalWrite(Apos, HIGH); + digitalWrite(Aneg, LOW); +} + +void counter_clockwise(){ + digitalWrite(Apos, LOW); + digitalWrite(Aneg, HIGH); +} + +void brake (){ + digitalWrite(Aenable, LOW); +} + +/** + * Vex = higher voltage that can power the motor and/or the shield as well as the Arduino if wanted + * 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself + * GND = ass always, the ground of everything + * B- = Connection of the first motor or first winding of the stepper motor + * B+ = Connection of the first motor or first winding of the stepper motor + * A- = Connection of the second motor or second winding of the stepper motor + * A+ = Connection of the second motor or second winding of the stepper motor + **/