This is single way communication with the PC

Dependencies:   mbed

Committer:
akverma
Date:
Wed Dec 28 22:59:38 2016 +0000
Revision:
1:dad12410fd2d
Serial communication both way, complete package.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akverma 1:dad12410fd2d 1 /*#include "mbed.h"
akverma 1:dad12410fd2d 2
akverma 1:dad12410fd2d 3 DigitalOut led1(LED1);
akverma 1:dad12410fd2d 4 DigitalOut led2(LED2);
akverma 1:dad12410fd2d 5 uint8_t data;
akverma 1:dad12410fd2d 6 Serial pc(USBTX, USBRX);
akverma 1:dad12410fd2d 7
akverma 1:dad12410fd2d 8 void call() {
akverma 1:dad12410fd2d 9 // Note: you need to actually read from the serial to clear the RX interrupt
akverma 1:dad12410fd2d 10 data = pc.getc();
akverma 1:dad12410fd2d 11 printf("%c\n", data);
akverma 1:dad12410fd2d 12 led2 = !led2;
akverma 1:dad12410fd2d 13 }
akverma 1:dad12410fd2d 14
akverma 1:dad12410fd2d 15 int main() {
akverma 1:dad12410fd2d 16 pc.attach(&call);
akverma 1:dad12410fd2d 17 while (1) {
akverma 1:dad12410fd2d 18 led1 = !led1;
akverma 1:dad12410fd2d 19 wait(0.5);
akverma 1:dad12410fd2d 20 }
akverma 1:dad12410fd2d 21 }*/