6 years, 8 months ago.

two way serial communication

hello, i am trying to sending string with 3 character by serial monitor and it will print what i want. but problem is that when i am trying to send more than 3 character string (pc.gets(buffer, 5);) it cant print always on serial monitor. why?? here is my program:

  1. include "mbed.h"

Serial pc(USBTX, USBRX, 9600);

int main() { char buffer[128];

while(1) { pc.gets(buffer, 4); if(strcmp(buffer,"sam")==0) { pc.printf("Hii '%s'\nWELCOME TO ARM Mbed.\n\n", buffer);

} } }

Be the first to answer this question.