-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStepper.h
More file actions
47 lines (36 loc) · 1018 Bytes
/
Stepper.h
File metadata and controls
47 lines (36 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef STEPPER_H
#define STEPPER_H
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#define CLOCKWISE 1
#define COUNTERCLOCKWISE 2
class Stepper {
private:
int pins[];
byte steps[];
unsigned int stepCount;
float stepsPerRotation;
float rotationsPerMinute;
float distancePerRotation;
byte direction;
unsigned int stepsRemaining;
unsigned int currentStepIndex;
unsigned int microsBetweenSteps;
unsigned int nextMicrosForStep;
public:
Stepper(int pins[],
byte steps[] = (byte[]){8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001},
float stepsPerRotation = 4075.7728395,
float rotationsPerMinute = 12,
float distancePerRotation = 200,
byte direction = CLOCKWISE);
void rotate(int rotations);
void rotateByDegrees(float degrees);
void move(float distance);
void run();
boolean isDone;
};
#endif