-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharduino_basic_frame.ino
More file actions
53 lines (39 loc) · 1.28 KB
/
arduino_basic_frame.ino
File metadata and controls
53 lines (39 loc) · 1.28 KB
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
//useful resource:
//https://www.hackerearth.com/blog/internet-of-things/arduino-programming-for-beginners/
//https://www.sunfounder.com/blog/rpi-ard/
//for reference to "serial" lib
//https://www.arduino.cc/reference/en/language/functions/communication/serial/
//initialize operation struct
struct operation{
int pipe_1;
int pipe_2;
//...
//specifying amound of each drink
}
int PUMP_1 = 13;
//....
//pre code each pump's corresponding output ping
operation pump_op
void setup ( )
{
Serial.begin(9600); //initialize port
pinMode (PUMP_1, OUTPUT); //set up PUMP pin for output
//...
//set the rest PUMP pin for output
}
void loop( ) // The loop function runs again and again
{
if (Serial.available() > 0) {
// read the incoming message:
pump_op = (pump_op)(Serial.read());
//or some where alone the line
//handle bad input
// processing incoming message
if(pump_op.pipe_1 > 0){
digitalWrite (PUMP_1,HIGH); // Turn ON the PUMP_N
delay (pump_op.pipe_1*1000); //Wait for specified time
digitalWrite (PUMP_1, LOW); //Turn OFF the PUMP_N
}
//...
}
}