-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine1.ino
110 lines (92 loc) · 2.44 KB
/
combine1.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <Stepper.h>
#include <max6675.h>
// Define pin connections & motor's steps per revolution
const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 200;
// Define pins for MAX6675
int thermoSO = 4;
int thermoCS = 5;
int thermoCLK = 6;
float preTemp = 0;
float soakTemp = 0;
float peakTemp = 0;
// initialize the stepper library:
Stepper myStepper(stepsPerRevolution, dirPin, stepPin, 4, 5, 6);
//intialize max6675 library:
MAX6675 thermocouple(thermoCLK, thermoCS, thermoSO);
void setup() {
// set the speed at 1000 rpm:
myStepper.setSpeed(1000);
// initialize the serial port:
Serial.begin(9600);
Serial.println("MAX6675 test");
// Prompt the user to enter the desired temperature range
Serial.println("Enter Preheat Temperature: ");
while (Serial.available()) {
Serial.read();
}
while(Serial.available() == 0){}
preTemp = Serial.parseInt();
Serial.println("Enter Soak Temperature: ");
while (Serial.available()) {
Serial.read();
}
while(Serial.available() == 0){}
soakTemp = Serial.parseInt();
Serial.println("Enter Peak Temperature: ");
while (Serial.available()) {
Serial.read();
}
while(Serial.available() == 0){
peakTemp = Serial.parseInt();
}
}
void loop () {
double temperature = thermocouple.readCelsius();
Serial.print("Temperature: ");
Serial.println(temperature);
delay (1000);
if (temperature < preTemp) {
Serial.println("clockwise");
myStepper.step(-stepsPerRevolution*10);
delay(200);
return;
}
if (temperature == preTemp) {
Serial.println("pause");
myStepper.step(0*10);
delay(2000);
return;
}
if (temperature > preTemp && temperature < soakTemp) {
Serial.println("clockwise");
myStepper.step(-stepsPerRevolution*10);
delay(200);
return;
}
if (temperature == soakTemp) {
Serial.println("pause");
myStepper.step(0*10);
delay(2000);
return;
}
if (temperature > soakTemp && temperature < peakTemp) {
Serial.println("clockwise");
myStepper.step(-stepsPerRevolution*10);
delay(200);
return;
}
if (temperature == peakTemp) {
Serial.println("pause");
myStepper.step(0*10);
delay(2000);
return;
}
if (temperature > peakTemp) {
Serial.println("counterclockwise");
myStepper.step(stepsPerRevolution*10);
delay(200);
return;
}
}