TaChing Yu / Mbed 2 deprecated Wifi_Relay

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 //------------------------------------
00004 // Hyperterminal configuration
00005 // 9600 bauds, 8-bit data, no parity
00006 //------------------------------------
00007 
00008 Serial esp8266(D6, D7);//tx, rx 
00009 DigitalOut led(D2);
00010 DigitalOut relay(D3);
00011  
00012 int main() {
00013     while(1){
00014         if (esp8266.readable()){
00015             char val = esp8266.getc();
00016             switch (val){
00017             case 'a':
00018             led = !led;
00019             break;
00020             case 'b':
00021             relay = !relay;
00022             break;
00023             }
00024             }    
00025   }
00026 }
00027