bamlormakmak

Dependencies:   mbed

main.cpp

Committer:
jaybehandsome
Date:
2017-12-08
Revision:
5:587de5c5fc38
Parent:
4:75962425e27b

File content as of revision 5:587de5c5fc38:

#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");
   for (x = 0; x<8; x++)
   {
       data[x] = NULL;
    }
   // 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] = bt.getc();
            if (data[x] == '!')
            {
                x = 0;
            }
//            if (x == 8)
//            {
//                x=0;
//            }
            pc.printf("%c%c%c%c%c%c%c%c",data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
            x++;

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

        }
    }
}