5 years, 7 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);
    }
}
Be the first to answer this question.