Project

General

Profile

Wiki » History » Version 3

Frédéric Blanc, 2023-11-15 15:58

1 3 Frédéric Blanc
h1. accelstepper
2
3
https://www.arduino.cc/reference/en/libraries/accelstepper/
4 2 Frédéric Blanc
5 1 Frédéric Blanc
<pre><code class="cpp">
6
7
8
9
#include <AccelStepper.h>
10
11
// for the Arduino Uno + CNC shield V3 + A4988 + FL42STH47-1684A
12
13
#define MOTOR_X_ENABLE_PIN 8
14
#define MOTOR_X_STEP_PIN 2
15
#define MOTOR_X_DIR_PIN 5
16
17
AccelStepper motor_X(1, MOTOR_X_STEP_PIN, MOTOR_X_DIR_PIN); 
18
19
20
void setup()
21
{
22
  motor_X.setEnablePin(MOTOR_X_ENABLE_PIN);
23
  motor_X.setPinsInverted(false, false, true);
24
  motor_X.setAcceleration(20);  
25
  motor_X.move(200);
26
  motor_X.setMaxSpeed(100);
27
  //motor_X.setSpeed(100);
28
  motor_X.enableOutputs();
29
}
30
31
void loop()
32
{
33
  motor_X.run();
34
}
35
</code></pre>