CHAT SERIAL

Dependencies:   mbed

main.cpp

Committer:
ABD931
Date:
2017-09-30
Revision:
0:6f1384d9a913

File content as of revision 0:6f1384d9a913:

//CODIGO PAR EL CHAT SERIAL

#include "mbed.h"
#include "SoftSerial.h"
#include <string>
/******************************************************************************/
char c;
SoftSerial con(D4,D5);//tx.rx
Serial pc(USBTX,USBRX);

/******************************************************************************/


int main (){
    //AnalogIn ai(A0);
    //lcd.locate(0,0);
    //wait(0.1);
   //lcd.locate(0,0);
    con.baud(9600);
    pc.baud(9600);
   
    wait(0.1);
    
    //lcd.cls();
    while (1)
    {
        while (pc.readable()>0)
        {
            con.putc(pc.getc());
         
        }
        
        while (con.readable()>0) 
        {
            pc.putc(con.getc());
            //lcd.printf("%s",readString);
        }
        wait(0.01);
        
        if (con.readable()>0)
            {
                c=con.getc();
              
                pc.printf("%c",c);
                //lcd.printf("%s",readString);
            wait(0.5);                
                }
                
    }
}