mBed with Arduino

Dependencies:   mbed

Fork of Serial_2 by TaChing Yu

Committer:
liuminhaw
Date:
Sun Sep 04 03:41:20 2016 +0000
Revision:
1:7b45959a62d9
Parent:
0:5d2615cbb0df
mbed with arduino

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yu10078999 0:5d2615cbb0df 1 #include "mbed.h"
liuminhaw 1:7b45959a62d9 2
liuminhaw 1:7b45959a62d9 3 #define esp8266 pc
liuminhaw 1:7b45959a62d9 4 DigitalOut led_extern(PB_15);
liuminhaw 1:7b45959a62d9 5 DigitalOut led(LED1);
liuminhaw 1:7b45959a62d9 6 //Serial pc(USBTX, USBRX);
liuminhaw 1:7b45959a62d9 7 Serial esp8266(PB_6, PB_7);
yu10078999 0:5d2615cbb0df 8 char val;
yu10078999 0:5d2615cbb0df 9 int main() {
liuminhaw 1:7b45959a62d9 10 pc.baud(115200);
liuminhaw 1:7b45959a62d9 11 //esp8266(115200);
yu10078999 0:5d2615cbb0df 12 while(1) {
yu10078999 0:5d2615cbb0df 13 if(pc.readable()) {
liuminhaw 1:7b45959a62d9 14 //pc.printf("Ready\n");
yu10078999 0:5d2615cbb0df 15 val = pc.getc();
yu10078999 0:5d2615cbb0df 16 if(val=='a'){
yu10078999 0:5d2615cbb0df 17 led = 1 ;
liuminhaw 1:7b45959a62d9 18 led_extern = 1;
liuminhaw 1:7b45959a62d9 19 //pc.printf("LED ON\n");
yu10078999 0:5d2615cbb0df 20 }
yu10078999 0:5d2615cbb0df 21 else if (val == 'b') {
yu10078999 0:5d2615cbb0df 22 led = 0;
liuminhaw 1:7b45959a62d9 23 led_extern = 0;
liuminhaw 1:7b45959a62d9 24 //pc.printf("LED OFF\n");
yu10078999 0:5d2615cbb0df 25 }
yu10078999 0:5d2615cbb0df 26 }
yu10078999 0:5d2615cbb0df 27 }
yu10078999 0:5d2615cbb0df 28 }