bamlormakmak

Dependencies:   mbed

main.cpp

Committer:
jaybehandsome
Date:
2017-12-08
Revision:
3:47af38e57498
Parent:
2:2f71623970f7
Child:
4:75962425e27b

File content as of revision 3:47af38e57498:

#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial bt(PA_15, PB_7);
int bye;
int main(void)
{
   char data[8] ;
   int x = 0;
   char recieve;
   pc.printf("Hello World\n");
   // char ch;
//    pc.baud(38400);
//    bt.baud(38400);
//    pc.printf("Hello World!\n\r");
//    bt.printf("Hello World!\r\n");
//    
//    while(1)
//    {
//        if(bt.readable())
//        {
//            ch=bt.getc();
//            pc.printf("%c",ch);
//        }
//        
//        else if(pc.readable())
//        {
//            ch=pc.getc();
//            bt.printf("%c",ch);
//        }
//    }
    while(1)
    {
        if(bt.readable())
        {
            data[x] = pc.getc();
            if (data[x] == '!')
            {
                x = 0;
            }
            if (x == 8)
            {
                x=0;
            }
            bt.putc(data[x]);
            x++;

        }
        if(pc.readable())
        {
            recieve = pc.getc();
            bt.putc(recieve);

        }
    }
}