-
Notifications
You must be signed in to change notification settings - Fork 0
/
FYP_2_Final_v1.ino
85 lines (83 loc) · 2.42 KB
/
FYP_2_Final_v1.ino
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <Servo.h>
#include <Stepper.h>
//--------------------------------------------------
//Gantry motor
//--------------------------------------------------
const int stepPin = 51;
const int dirPin = 50;
const int stepPin2 = 42;
const int dirPin2 = 43;
//--------------------------------------------------
//Servo Blade
//--------------------------------------------------
Servo ServoBlade;
int posBlade=0;
//--------------------------------------------------
//
//--------------------------------------------------
// initialize the stepper library on pins 8 through 11:
//Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
//--------------------------------------------------
//
//--------------------------------------------------
void setup() {
Serial.begin(9600);
//--------------------------------------------------
//
//--------------------------------------------------
ServoBlade.attach(6);
//--------------------------------------------------
// Limit switch motor
//--------------------------------------------------
pinMode(12, INPUT);
pinMode(11, INPUT);
pinMode(10, INPUT);
pinMode(9, INPUT);
//--------------------------------------------------
//Gantry motor
//--------------------------------------------------
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(stepPin2,OUTPUT);
pinMode(dirPin2,OUTPUT);
//--------------------------------------------------
//
//--------------------------------------------------
}
//--------------------------------------------------
//
//--------------------------------------------------
void loop() {
Limitswitch();
//Blade();
}
//--------------------------------------------------
//
//--------------------------------------------------
void Limitswitch(){
if(digitalRead(12)==0){
Serial.println("arm right");
}
else if (digitalRead(11)==0){
Serial.println("Gantry back");
}
else if (digitalRead(10)==0){
Serial.println("arm left");
}
else if (digitalRead(9)==0){
Serial.println("gantry forward");
}
}
//--------------------------------------------------
//
//--------------------------------------------------
void Blade(){
for (posBlade = 0; posBlade <= 180; posBlade += 1) {
ServoBlade.write(posBlade);
delay(15);
}
for (posBlade = 180; posBlade >= 0; posBlade -= 1) {
ServoBlade.write(posBlade);
delay(15);
}
}