Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 6 months ago.
Saving string from (RX,TX) to an array only when you press enter
Hello! I need help to store a string data type coming from a Bluetooth serial module (HC-05) (RX, TX) in an array. I have tried the following code, but I need the data to be stored in an array only when the enter key of the computer is pressed, thanks
serialtoarray
#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial device(PA_9, PA_10);
int main() {
volatile char command[8];
while(1) {
device.scanf("%7s", command);
pc.printf("%s\r\n", command);
}
}