Skip to content

Instantly share code, notes, and snippets.

@J3698
Last active July 22, 2018 00:42
Show Gist options
  • Save J3698/ab69434e4eb814a8f70d96cdeba57c2a to your computer and use it in GitHub Desktop.
Save J3698/ab69434e4eb814a8f70d96cdeba57c2a to your computer and use it in GitHub Desktop.
Send and retrieve the Bluetooth module's settings
void setup() {
// Start the serial monitor
/*
Note: make sure the serial monitor's
baud rate is set to 115,200
*/
Serial.begin(115200);
// Start communication with the Bluetooth module
Serial1.begin(115200);
delay(100);
}
void loop() {
// Get user input
String toBluetooth = "";
while (Serial.available()) {
toBluetooth += (char) Serial.read();
}
// Send user input to the Bluetooth module
Serial1.print(toBluetooth);
// Get Bluetooth module output
String toPc = "";
while (Serial1.available()) {
toPc += (char) Serial1.read();
}
// Send Bluetooth module output to serial monitor
Serial.print(toPc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment