-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode
More file actions
61 lines (40 loc) · 1.25 KB
/
Copy pathcode
File metadata and controls
61 lines (40 loc) · 1.25 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Written By: Jeremy Fielding. This is in reference to my clock video here.
//---- What follows but commented out is my son's original code. I updated it to be more unversally useable below.
// you will need to install the accelstepper library for it to work.
//defines pins used for information
//const int stepPin = 3;
//const int dirPin = 4;
//int RPM = 6; // sets RPM
//void setup() {
//sets the two info pins as outputs
//pinMode(stepPin,OUTPUT);
//pinMode(dirPin,OUTPUT);
//}
//void loop() {
//High = clockwise Low = Counter clockwise
//digitalWrite(stepPin,HIGH);
//delayMicroseconds(18750 / RPM);
//digitalWrite(stepPin,LOW);
//delayMicroseconds(18750 / RPM);
//}
//---------
#include <AccelStepper.h>
//Defining pins
int Stepper1Pulse = 5; // Pulse or step pin
int Stepper1Direction = 6; // Direction pin
//defining terms
int Motor1speed = 1000;
AccelStepper step1(1, Stepper1Pulse, Stepper1Direction);
void setup() {
step1.setMaxSpeed (speedmax);
step1.setSpeed(0);
step1.setAcceleration(1000);
pinMode(Stepper1Pulse, OUTPUT);
pinMode(Stepper1Direction, OUTPUT);
digitalWrite(Stepper1Pulse, LOW);
digitalWrite(Stepper1Direction, LOW);
}
void loop() {
step1.setSpeed(Motor1speed);
step1.runSpeed();
}