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
|
#include <Stepper.h>
#define STEPS 200
#define motorInterfaceType 1
//------stepper motor for carousel----------
Stepper stepper(STEPS, 2, 3); // Pin 2 connected to DIRECTION & Pin 3 connected to STEP Pin of Driver
int stepperSleepPin = 0;
int stepperCounter = 0;
//------linear actuator for doseing-----------
int doesActivatePin = 0;
int doesDeactivatePin = 0;
void setup() {
stepper.setSpeed(1000);
pinMode(stepperSleepPin, OUTPUT);
//Sleeps motor to stop overheating
digitalWrite(stepperSleepPin, HIGH);
pinMode(doesActivatePin, OUTPUT);
pinMode(doesDeactivatePin, OUTPUT);
}
void loop() {
//-------Wait for MQTT BROKER message--------//
}
//-------------Dosing valve activation----------------//
void doesAlcohol(){
digitalWrite(doesActivatePin, HIGH);
delay(5000);
digitalWrite(doesActivatePin, LOW);
digitalWrite(doesDeactivatePin, HIGH);
delay(2000);
digitalWrite(doesDeactivatePin, LOW);
//Send message for done doesing
}
//-------------Carousel activation----------------//
void runCarousel(int steps){
//Wakes up motor to run
digitalWrite(stepperSleepPin, LOW);
//---------Add acceleration to save motor from inertia from the carousel--------//
stepper.step(steps);
stepperCounter = stepperCounter + steps;
//Sleeps motor to stop overheating
digitalWrite(stepperSleepPin, HIGH);
//Send message for done runing
}
//-------------Pumps activation----------------//
void activatePump(int pump, int time){
pinMode(pump, OUTPUT);
digitalWrite(pump, HIGH);
delay(time);
digitalWrite(pump, LOW);
//Send message for done pumping
}
|