kumaresh kj / Mbed 2 deprecated Nucleo103_serial_Button_output

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 // default 9600 bauds, 8-bit data, no parity
00006 
00007 //Arduino pin D0 & D1 is disconnected by default in nucleo board and hence serial O/P or I/P will not work.
00008 // REFER ST USER MANUAL UM 1724
00009 
00010 //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. 
00011 // use any terminal software and open the COM port of ST link to see the output.
00012 //------------------------------------
00013 
00014 Serial pc(SERIAL_TX, SERIAL_RX);
00015 DigitalIn sw1( PC_13);           // refer UM1724 ST nucleo User manual for pin details
00016 
00017  
00018 DigitalOut myled(LED1);
00019  
00020 int main() {
00021   int i = 1;
00022   pc.printf("Hello World !\n");
00023   while(1) { 
00024       if (sw1 == 0) { 
00025       pc.printf("count = %d.\n", i++);
00026       myled = !myled;
00027       while(!sw1);  // wait till switch release
00028       }
00029   }
00030 }
00031