Project

General

Profile

Wiki » History » Version 1

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

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