From d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 10 Jul 2025 22:55:07 +0200 Subject: Add new code Signed-off-by: Carlos Maiolino --- .../examples/DualMotorShield/DualMotorShield.pde | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Arduino/libraries/AccelStepper/examples/DualMotorShield/DualMotorShield.pde (limited to 'Arduino/libraries/AccelStepper/examples/DualMotorShield') diff --git a/Arduino/libraries/AccelStepper/examples/DualMotorShield/DualMotorShield.pde b/Arduino/libraries/AccelStepper/examples/DualMotorShield/DualMotorShield.pde new file mode 100644 index 0000000..1ca70b1 --- /dev/null +++ b/Arduino/libraries/AccelStepper/examples/DualMotorShield/DualMotorShield.pde @@ -0,0 +1,49 @@ +// DualMotorShield.pde +// -*- mode: C++ -*- +// +// Shows how to run 2 simultaneous steppers +// using the Itead Studio Arduino Dual Stepper Motor Driver Shield +// model IM120417015 +// This shield is capable of driving 2 steppers at +// currents of up to 750mA +// and voltages up to 30V +// Runs both steppers forwards and backwards, accelerating and decelerating +// at the limits. +// +// Copyright (C) 2014 Mike McCauley +// $Id: $ + +#include + +// The X Stepper pins +#define STEPPER1_DIR_PIN 3 +#define STEPPER1_STEP_PIN 2 +// The Y stepper pins +#define STEPPER2_DIR_PIN 7 +#define STEPPER2_STEP_PIN 6 + +// Define some steppers and the pins the will use +AccelStepper stepper1(AccelStepper::DRIVER, STEPPER1_STEP_PIN, STEPPER1_DIR_PIN); +AccelStepper stepper2(AccelStepper::DRIVER, STEPPER2_STEP_PIN, STEPPER2_DIR_PIN); + +void setup() +{ + stepper1.setMaxSpeed(200.0); + stepper1.setAcceleration(200.0); + stepper1.moveTo(100); + + stepper2.setMaxSpeed(100.0); + stepper2.setAcceleration(100.0); + stepper2.moveTo(100); +} + +void loop() +{ + // Change direction at the limits + if (stepper1.distanceToGo() == 0) + stepper1.moveTo(-stepper1.currentPosition()); + if (stepper2.distanceToGo() == 0) + stepper2.moveTo(-stepper2.currentPosition()); + stepper1.run(); + stepper2.run(); +} -- cgit v1.2.3