-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBartender_fixed.ino
137 lines (127 loc) · 2.84 KB
/
Bartender_fixed.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// select the input pin for the potentiometer
// select the pin for the LED
// variable to store the value coming from the sensor
int btn1 = 0, btn2 = 0, btn3 = 0, btn4 = 0;
char bluetooth = 'E';
int btn1Pin = 11;
int btn2Pin = 12;
int btn3Pin = 13;
int btn4Pin = 14;
int bluetoothPin = 15;
int Drink1Pin = 16;
int Drink2Pin = 17;
int Mixer1Pin = 18;
int Mixer2Pin = 19;
int Mixer3Pin = 20;
class DrinkProfile{
public:
int Mixer1;
int Mixer2;
int Mixer3;
int Drink1;
int Drink2;
void MakeDrink();
};
void DrinkProfile::MakeDrink() {
if( Drink1 == 1) {
digitalWrite( Drink1Pin, HIGH);
delay(100);
digitalWrite(Drink1Pin, LOW);
}
if( Drink2 == 1) {
digitalWrite( Drink2Pin, HIGH);
delay(100);
digitalWrite(Drink2Pin, LOW);
}
if( Mixer1 == 1 ) {
digitalWrite( Mixer1Pin, HIGH);
delay(300);
digitalWrite( Mixer1Pin, LOW);
}
if( Mixer2 == 1 ) {
digitalWrite( Mixer2Pin, HIGH);
delay(300);
digitalWrite( Mixer2Pin, LOW);
}
if( Mixer3 == 1 ) {
digitalWrite( Mixer2Pin, HIGH);
delay(300);
digitalWrite( Mixer2Pin, LOW);
}
}
DrinkProfile A, B, C, D;
void setup() {
A.Drink1 = 1;
A.Mixer1 = 1;
B.Drink2 = 1;
B.Mixer2 = 1;
C.Drink1 = 1;
C.Mixer2 = 1;
C.Mixer3 = 1;
D.Drink2 = 1;
D.Mixer3 = 1;
pinMode(Drink1Pin, OUTPUT);
pinMode(Drink2Pin, OUTPUT);
pinMode(Mixer1Pin, OUTPUT);
pinMode(Mixer2Pin, OUTPUT);
pinMode(Mixer3Pin, OUTPUT);
pinMode(btn1Pin, INPUT);
pinMode(btn2Pin, INPUT);
pinMode(btn3Pin, INPUT);
pinMode(btn4Pin, INPUT);
pinMode(bluetoothPin, INPUT);
Serial.begin(9600);
}
void loop() {
//DrinkProfile selection;
//signal = recieve_instruct()
//if( btn1 == 1 ){
//selection = profile1
//}
//else if.....
//makedrink(selection)
btn1 = digitalRead( btn1Pin );
btn2 = digitalRead( btn2Pin );
btn3 = digitalRead( btn3Pin );
btn4 = digitalRead( btn4Pin );
bluetooth = digitalRead(bluetoothPin); // ???Seems to be a problem here
if( btn1 == 1 ){
//selection = A;
A.MakeDrink();
}
else if( btn2 == 1 ){
//selection = B;
B.MakeDrink();
}
else if( btn3 == 1 ){
//selection = C;
C.MakeDrink();
}
else if( btn4 == 1 ){
//selection = D;
D.MakeDrink();
}
else {
if (Serial.available() > 0){
bluetooth = Serial.read(); //Serial.read only reads the first byte as int
//Need to test the value in the bluetooth, is it the ASCII decimal or the characater
}
if( bluetooth == 'A'){
//selection = A;
A.MakeDrink();
}
else if( bluetooth == 'B'){
//selection = B;
B.MakeDrink();
}
else if( bluetooth == 'C'){
//selection = C;
C.MakeDrink();
}
else if( bluetooth == 'D'){
//selection = D;
D.MakeDrink();
}
}
//Serial.println(sensorValue, DEC);
}