kumaresh kj
/
Nucleo103_serial_Button_output
serial output control using switch
Diff: main.cpp
- Revision:
- 0:b1e04d4268b3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 20 10:58:58 2015 +0000 @@ -0,0 +1,31 @@ +#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 + } + } +} + \ No newline at end of file