-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtestSerial.ino
More file actions
38 lines (26 loc) · 755 Bytes
/
testSerial.ino
File metadata and controls
38 lines (26 loc) · 755 Bytes
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
#include <SoftwareSerial.h>
// Enter commands in the serial monitor and send them to the GSM modules and view the response
SoftwareSerial SIM900(2, 3);
// SoftwareSerial SIM900(7, 8);
void setup() {
SIM900.begin(9600);
Serial.begin(9600);
Serial.println("Enter command");
}
void loop() {
if (Serial.available()) {
String command = Serial.readStringUntil('\n');
Serial.println("C: " + command);
sendCommand(command);
delay(2000);
}
// Check if a complete line of response is available
if (SIM900.available()) {
String response = SIM900.readString();
Serial.println("Response: " + response);
// sendResponse(response);
}
}
void sendCommand(String command) {
SIM900.println(command);
}