serial output control using switch

Dependencies:   mbed

Committer:
kumaresh
Date:
Mon Apr 20 10:58:58 2015 +0000
Revision:
0:b1e04d4268b3
serial output control using switch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kumaresh 0:b1e04d4268b3 1 #include "mbed.h"
kumaresh 0:b1e04d4268b3 2
kumaresh 0:b1e04d4268b3 3 //------------------------------------
kumaresh 0:b1e04d4268b3 4 // Hyperterminal configuration
kumaresh 0:b1e04d4268b3 5 // default 9600 bauds, 8-bit data, no parity
kumaresh 0:b1e04d4268b3 6
kumaresh 0:b1e04d4268b3 7 //Arduino pin D0 & D1 is disconnected by default in nucleo board and hence serial O/P or I/P will not work.
kumaresh 0:b1e04d4268b3 8 // REFER ST USER MANUAL UM 1724
kumaresh 0:b1e04d4268b3 9
kumaresh 0:b1e04d4268b3 10 //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.
kumaresh 0:b1e04d4268b3 11 // use any terminal software and open the COM port of ST link to see the output.
kumaresh 0:b1e04d4268b3 12 //------------------------------------
kumaresh 0:b1e04d4268b3 13
kumaresh 0:b1e04d4268b3 14 Serial pc(SERIAL_TX, SERIAL_RX);
kumaresh 0:b1e04d4268b3 15 DigitalIn sw1( PC_13); // refer UM1724 ST nucleo User manual for pin details
kumaresh 0:b1e04d4268b3 16
kumaresh 0:b1e04d4268b3 17
kumaresh 0:b1e04d4268b3 18 DigitalOut myled(LED1);
kumaresh 0:b1e04d4268b3 19
kumaresh 0:b1e04d4268b3 20 int main() {
kumaresh 0:b1e04d4268b3 21 int i = 1;
kumaresh 0:b1e04d4268b3 22 pc.printf("Hello World !\n");
kumaresh 0:b1e04d4268b3 23 while(1) {
kumaresh 0:b1e04d4268b3 24 if (sw1 == 0) {
kumaresh 0:b1e04d4268b3 25 pc.printf("count = %d.\n", i++);
kumaresh 0:b1e04d4268b3 26 myled = !myled;
kumaresh 0:b1e04d4268b3 27 while(!sw1); // wait till switch release
kumaresh 0:b1e04d4268b3 28 }
kumaresh 0:b1e04d4268b3 29 }
kumaresh 0:b1e04d4268b3 30 }
kumaresh 0:b1e04d4268b3 31