serial output control using switch

Dependencies:   mbed

main.cpp

Committer:
kumaresh
Date:
2015-04-20
Revision:
0:b1e04d4268b3

File content as of revision 0:b1e04d4268b3:

#include "mbed.h"

//------------------------------------
// Hyperterminal configuration
// default 9600 bauds, 8-bit data, no parity

//Arduino pin D0 & D1 is disconnected by default in nucleo board and hence serial O/P or I/P will not work.
// REFER ST USER MANUAL UM 1724

//O/P/ or I/P will work in ST link(USB to serial virtual com port) or can also be used from CN3 connector of nucleo board. 
// use any terminal software and open the COM port of ST link to see the output.
//------------------------------------

Serial pc(SERIAL_TX, SERIAL_RX);
DigitalIn sw1( PC_13);           // refer UM1724 ST nucleo User manual for pin details

 
DigitalOut myled(LED1);
 
int main() {
  int i = 1;
  pc.printf("Hello World !\n");
  while(1) { 
      if (sw1 == 0) { 
      pc.printf("count = %d.\n", i++);
      myled = !myled;
      while(!sw1);  // wait till switch release
      }
  }
}