Created
July 21, 2018 23:43
-
-
Save J3698/3d1e19666feb7a5fd9ae1324314fc29d to your computer and use it in GitHub Desktop.
Using both the Serial Monitor and a Bluetooth module on RX/TX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
String debug = ""; | |
// Begin the serial monitor | |
Serial.begin(115200); | |
/* | |
I use delays to ensure certain things | |
have had time to settle and for | |
debugging - some are probably extraneous | |
*/ | |
delay(1000); | |
// Send commands to the Bluetooth module | |
Serial.print("$$$"); | |
delay(100); | |
Serial.print("x\r"); | |
delay(300); | |
// Store output to a string | |
while(Serial.available()) { | |
debug += (char) Serial.read(); | |
} | |
// Send more commands to the Bluetooth module | |
Serial.print("---\r"); | |
delay(100); | |
// Store more output to the string | |
while (Serial.available()) { | |
debug += (char) Serial.read(); | |
} | |
/* | |
Both the Bluetooth module and serial monitor | |
will recieve this - it's okay that the Bluetooth | |
module gets this, as the program is now done. | |
*/ | |
Serial.print("\nsaid: \"" + debug + "\""); | |
} | |
void loop() { | |
delay(1000); | |
digitalWrite(13, HIGH); | |
delay(1000); | |
digitalWrite(13, LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment