yasaswini hajira / Mbed 2 deprecated mbed_serial

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 BusOut myled(LED1,LED2,LED3,LED4);
00003 Serial pc(USBTX,USBRX);
00004 char i;
00005 int main() {
00006     
00007     while(1)
00008     {
00009           pc.printf("press the key\n\r"); 
00010           pc.scanf("%c",&i); 
00011          
00012          if(i=='q')
00013          {   
00014         myled=0x01;
00015         pc.printf("led1 is blinking\n\r");
00016         wait(0.2);
00017         myled=0x00;
00018         wait(0.2);
00019         }
00020         if(i=='w')
00021         {
00022         myled=0x02;
00023         pc.printf("led2 is blinking\n\r");
00024         wait(0.2);
00025         myled=0x00;
00026         wait(0.2);
00027         }
00028         if(i=='e')
00029         {
00030         myled=0x04;
00031         pc.printf("led3 is blinking\n\r");
00032         wait(0.2);
00033         myled=0x00;
00034         wait(0.2);
00035         }
00036         if(i=='r')
00037         {
00038         myled=0x08;
00039         pc.printf("led4 is blinking\n\r");
00040         wait(0.2);
00041         myled=0x00;
00042         wait(0.2);
00043         }
00044     }
00045 }