bamlormakmak
Dependencies: mbed
main.cpp@4:75962425e27b, 2017-12-08 (annotated)
- Committer:
- jaybehandsome
- Date:
- Fri Dec 08 20:34:25 2017 +0000
- Revision:
- 4:75962425e27b
- Parent:
- 3:47af38e57498
- Child:
- 5:587de5c5fc38
fucking bluetooth;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jaybehandsome | 0:0216e64ccf1b | 1 | #include "mbed.h" |
jaybehandsome | 0:0216e64ccf1b | 2 | Serial pc(USBTX, USBRX); |
jaybehandsome | 0:0216e64ccf1b | 3 | Serial bt(PA_15, PB_7); |
jnjtnutty | 1:1197e9258bc7 | 4 | int bye; |
jaybehandsome | 0:0216e64ccf1b | 5 | int main(void) |
jaybehandsome | 0:0216e64ccf1b | 6 | { |
jaybehandsome | 2:2f71623970f7 | 7 | char data[8] ; |
jaybehandsome | 2:2f71623970f7 | 8 | int x = 0; |
jaybehandsome | 3:47af38e57498 | 9 | char recieve; |
jaybehandsome | 2:2f71623970f7 | 10 | pc.printf("Hello World\n"); |
jnjtnutty | 1:1197e9258bc7 | 11 | // char ch; |
jnjtnutty | 1:1197e9258bc7 | 12 | // pc.baud(38400); |
jnjtnutty | 1:1197e9258bc7 | 13 | // bt.baud(38400); |
jnjtnutty | 1:1197e9258bc7 | 14 | // pc.printf("Hello World!\n\r"); |
jnjtnutty | 1:1197e9258bc7 | 15 | // bt.printf("Hello World!\r\n"); |
jnjtnutty | 1:1197e9258bc7 | 16 | // |
jnjtnutty | 1:1197e9258bc7 | 17 | // while(1) |
jnjtnutty | 1:1197e9258bc7 | 18 | // { |
jnjtnutty | 1:1197e9258bc7 | 19 | // if(bt.readable()) |
jnjtnutty | 1:1197e9258bc7 | 20 | // { |
jnjtnutty | 1:1197e9258bc7 | 21 | // ch=bt.getc(); |
jnjtnutty | 1:1197e9258bc7 | 22 | // pc.printf("%c",ch); |
jnjtnutty | 1:1197e9258bc7 | 23 | // } |
jnjtnutty | 1:1197e9258bc7 | 24 | // |
jnjtnutty | 1:1197e9258bc7 | 25 | // else if(pc.readable()) |
jnjtnutty | 1:1197e9258bc7 | 26 | // { |
jnjtnutty | 1:1197e9258bc7 | 27 | // ch=pc.getc(); |
jnjtnutty | 1:1197e9258bc7 | 28 | // bt.printf("%c",ch); |
jnjtnutty | 1:1197e9258bc7 | 29 | // } |
jnjtnutty | 1:1197e9258bc7 | 30 | // } |
jaybehandsome | 0:0216e64ccf1b | 31 | while(1) |
jaybehandsome | 0:0216e64ccf1b | 32 | { |
jaybehandsome | 0:0216e64ccf1b | 33 | if(bt.readable()) |
jaybehandsome | 0:0216e64ccf1b | 34 | { |
jaybehandsome | 3:47af38e57498 | 35 | data[x] = pc.getc(); |
jaybehandsome | 3:47af38e57498 | 36 | if (data[x] == '!') |
jaybehandsome | 2:2f71623970f7 | 37 | { |
jaybehandsome | 2:2f71623970f7 | 38 | x = 0; |
jaybehandsome | 2:2f71623970f7 | 39 | } |
jaybehandsome | 4:75962425e27b | 40 | // if (x == 8) |
jaybehandsome | 4:75962425e27b | 41 | // { |
jaybehandsome | 4:75962425e27b | 42 | // x=0; |
jaybehandsome | 4:75962425e27b | 43 | // } |
jaybehandsome | 4:75962425e27b | 44 | 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]); |
jaybehandsome | 2:2f71623970f7 | 45 | x++; |
jaybehandsome | 2:2f71623970f7 | 46 | |
jaybehandsome | 0:0216e64ccf1b | 47 | } |
jnjtnutty | 1:1197e9258bc7 | 48 | if(pc.readable()) |
jaybehandsome | 0:0216e64ccf1b | 49 | { |
jaybehandsome | 3:47af38e57498 | 50 | recieve = pc.getc(); |
jaybehandsome | 3:47af38e57498 | 51 | bt.putc(recieve); |
jaybehandsome | 3:47af38e57498 | 52 | |
jaybehandsome | 0:0216e64ccf1b | 53 | } |
jaybehandsome | 0:0216e64ccf1b | 54 | } |
jaybehandsome | 0:0216e64ccf1b | 55 | } |