Project

General

Profile

Wiki » History » Version 2

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

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