Skip to content

Commit ebfa77f

Browse files
author
Rishi Sharma
committed
Fixed game bug and added new pump functions
1 parent ad1ca3e commit ebfa77f

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

Drinking-Machine-Arduino-Code.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void setup() {
3131
Serial.begin(9600);
3232
Serial1.begin(9600);
3333
currentState = START_STATE;
34+
// have to decide when to prime and clear pumps
3435
}
3536

3637
enum stateMachine startState () {

libraries/GameControl/GameControl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ bool GameControl::checkPlinko() {
2121
return false;
2222
}
2323
void GameControl::returnGameResult(int &a, int &b) {
24+
Serial.println(readAsLowBin);
2425
switch (readAsLowBin) {
2526
case 0: a=4;b=0;break;
2627
case 1: a=3;b=1;break;
2728
case 2: a=0;b=0;break;
2829
case 3: a=2;b=2;break;
29-
case 4: a=1;b=3;break;
30-
case 5: a=0;b=0;break;
30+
case 4: a=0;b=0;break;
31+
case 5: a=1;b=3;break;
3132
case 6: a=0;b=4;break;
3233
default: a=0;b=0;break;
3334
}

libraries/PumpControl/PumpControl.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,36 @@ PumpControl::PumpControl()
99
}
1010

1111
// 4 UNITS MAKE ONE TOTAL DRINK
12+
13+
void PumpControl::primeA() {
14+
digitalWrite(motorSetAFor, HIGH);
15+
delay(FLOW_TOTAL_LENGTH_TIME_A);
16+
digitalWrite(motorSetAFor, LOW);
17+
}
18+
void PumpControl::primeB() {
19+
digitalWrite(motorSetBFor, HIGH);
20+
delay(FLOW_TOTAL_LENGTH_TIME_B);
21+
digitalWrite(motorSetBFor, LOW);
22+
}
23+
void PumpControl::clearA() {
24+
digitalWrite(motorSetABack, HIGH);
25+
delay(FLOW_TOTAL_LENGTH_TIME_A);
26+
digitalWrite(motorSetABack, LOW);
27+
}
28+
void PumpControl::clearB() {
29+
digitalWrite(motorSetBBack, HIGH);
30+
delay(FLOW_TOTAL_LENGTH_TIME_B);
31+
digitalWrite(motorSetBBack, LOW);
32+
}
1233
void PumpControl::dispense (int unitsOfA, int unitsOfB) {
1334
if (unitsOfA != 0) {
1435
digitalWrite(motorSetAFor, HIGH);
15-
delay(FLOW_TOTAL_LENGTH_TIME_A);
1636
delay(UNIT_OF_LIQUID_A * unitsOfA);
1737
digitalWrite(motorSetAFor, LOW);
1838
// can reverse here to clear pipe
1939
}
2040
if (unitsOfB != 0) {
2141
digitalWrite(motorSetBFor, HIGH);
22-
delay(FLOW_TOTAL_LENGTH_TIME_B);
2342
delay(UNIT_OF_LIQUID_B * unitsOfB);
2443
digitalWrite(motorSetBFor, LOW);
2544
// can reverse here to clear pipe

libraries/PumpControl/PumpControl.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55

66
#define FLOW_TOTAL_LENGTH_TIME_A 1000
77
#define FLOW_TOTAL_LENGTH_TIME_B 1000
8-
#define UNIT_OF_LIQUID_A 1
9-
#define UNIT_OF_LIQUID_B 1
8+
#define UNIT_OF_LIQUID_A 12500
9+
#define UNIT_OF_LIQUID_B 18518
1010

1111
class PumpControl
1212
{
1313
public:
1414
PumpControl();
1515

1616
// The methods
17+
void primeA();
18+
void primeB();
19+
void clearA();
20+
void clearB();
1721
void dispense(int unitsOfA, int unitsOfB);
1822
};
1923
#endif

0 commit comments

Comments
 (0)