-
Notifications
You must be signed in to change notification settings - Fork 0
/
stepper_arduino
70 lines (47 loc) · 1.19 KB
/
stepper_arduino
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
62
63
64
65
66
67
68
69
int Distance = 0;
int a;
int i;
void setup()
{
// Record the number of steps we've taken void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
Serial.begin(9600);
Serial.print("shar");
}
void loop()
{
if(Serial.available() > 0)
{
a = Serial.read();
}
if (a == 49)
{
Serial.println(a);
for(Distance = 0 ; Distance < 140; Distance++)
{
digitalWrite(9, HIGH);
delay(0.01);
digitalWrite(9, LOW);
delay(0.01);
Serial.println(Distance);// record this step // Check to see if we are at the end of our move
}
}
/*for(Distance = 0 ; Distance < 26; Distance++)
digitalWrite(9, HIGH);
delay(0.01);
digitalWrite(9, LOW);
delay(0.01);
Serial.println(Distance);// record this step // Check to see if we are at the end of our move
// two rotation for 1/8 bridge and 1 rotation for 1/6 bridge (for this code)
if (Distance == 7000) { // We are! Reverse direction (invert DIR signal)
if (digitalRead(8) == LOW) {
digitalWrite(8, HIGH); }
else {
digitalWrite(8, LOW);
} // Reset our distance back to zero since we're // starting a new move
Distance = 0; // Now pause for half a second delay(500);
}*/
}