11 years, 11 months ago.

serial PC to MBED

Dear All, how to know the serial work in the example "Pass through characters in both directions between the PC and Serial Port" ? I used pin 28&27)

#include "mbed.h"
 
Serial pc(USBTX, USBRX);
Serial uart(p28, p27);
 
DigitalOut pc_activity(LED1);
DigitalOut uart_activity(LED2);
 
int main() {
    while(1) {
        if(pc.readable()) {
            uart.putc(pc.getc());
            pc_activity = !pc_activity;
        }
        if(uart.readable()) {
            pc.putc(uart.getc());
            uart_activity = !uart_activity;
        }
    }
}

I have compile and its success, and I connected the MBED with max232 (the circuit http://sodoityourself.com/max232-serial-level-converter/) and connect with USB to serial converter to my laptop. and how to make it, if i would like to send a character from laptop and MBED respon it.

Thank you

Be the first to answer this question.