bamlormakmak

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 Serial pc(USBTX, USBRX);
00003 Serial bt(PA_15, PB_7);
00004 int bye;
00005 int main(void)
00006 {
00007    char data[8] ;
00008    int x = 0;
00009    char recieve;
00010    pc.printf("Hello World\n");
00011    for (x = 0; x<8; x++)
00012    {
00013        data[x] = NULL;
00014     }
00015    // char ch;
00016 //    pc.baud(38400);
00017 //    bt.baud(38400);
00018 //    pc.printf("Hello World!\n\r");
00019 //    bt.printf("Hello World!\r\n");
00020 //    
00021 //    while(1)
00022 //    {
00023 //        if(bt.readable())
00024 //        {
00025 //            ch=bt.getc();
00026 //            pc.printf("%c",ch);
00027 //        }
00028 //        
00029 //        else if(pc.readable())
00030 //        {
00031 //            ch=pc.getc();
00032 //            bt.printf("%c",ch);
00033 //        }
00034 //    }
00035     while(1)
00036     {
00037         if(bt.readable())
00038         {
00039             data[x] = bt.getc();
00040             if (data[x] == '!')
00041             {
00042                 x = 0;
00043             }
00044 //            if (x == 8)
00045 //            {
00046 //                x=0;
00047 //            }
00048             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]);
00049             x++;
00050 
00051         }
00052         if(pc.readable())
00053         {
00054             recieve = pc.getc();
00055             bt.putc(recieve);
00056 
00057         }
00058     }
00059 }