-
Notifications
You must be signed in to change notification settings - Fork 0
/
hub_program.ino
57 lines (42 loc) · 1004 Bytes
/
hub_program.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
#include <SoftwareSerial.h>
SoftwareSerial portFemale1(10, 11);
SoftwareSerial portFemale2(8, 9);
SoftwareSerial portFemale3(6, 7);
String readString;
String writeString;
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
portFemale1.begin(9600);
portFemale2.begin(9600);
portFemale3.begin(9600);
}
void loop() {
//if(portFemale1.read() != -1) {
portFemale1.listen();
softSerialEvent(portFemale1);
delay(5);
//}
//if(portFemale2.read() != -1) {
portFemale2.listen();
softSerialEvent(portFemale2);
delay(5);
//}
//if(portFemale3.read() != -1) {
portFemale3.listen();
softSerialEvent(portFemale3);
delay(5);
//}
Serial.println();
}
int softSerialEvent(SoftwareSerial &port)
{
readString = port.readStringUntil('|');
if (readString.length() > 0) {
Serial.println(readString);
}
return readString[3] == 'B';
}