Thomas Fischer / Mbed 2 deprecated mbed_LPC11U24_serial

Dependencies:   mbed

Committer:
tfischer72
Date:
Wed Jan 10 09:23:01 2018 +0000
Revision:
0:910a2d3aac71
FH Campus Wien Serial USART Lab6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tfischer72 0:910a2d3aac71 1 #include "mbed.h"
tfischer72 0:910a2d3aac71 2
tfischer72 0:910a2d3aac71 3 DigitalOut myled1(LED1);
tfischer72 0:910a2d3aac71 4 DigitalOut myled2(LED2);
tfischer72 0:910a2d3aac71 5 DigitalOut myled3(LED3);
tfischer72 0:910a2d3aac71 6 DigitalOut myled4(LED4);
tfischer72 0:910a2d3aac71 7 Serial pc(p9, p10); // tx, rx
tfischer72 0:910a2d3aac71 8
tfischer72 0:910a2d3aac71 9 int main() {
tfischer72 0:910a2d3aac71 10 pc.baud(9600);
tfischer72 0:910a2d3aac71 11 pc.printf("Hello from mbed!\n");
tfischer72 0:910a2d3aac71 12 while(1) {
tfischer72 0:910a2d3aac71 13 if(pc.readable()) {
tfischer72 0:910a2d3aac71 14 char c = pc.getc();
tfischer72 0:910a2d3aac71 15 if(c == '1') {
tfischer72 0:910a2d3aac71 16 myled1 = 1;
tfischer72 0:910a2d3aac71 17 wait(1.0);
tfischer72 0:910a2d3aac71 18 }
tfischer72 0:910a2d3aac71 19 if(c == '2') {
tfischer72 0:910a2d3aac71 20 myled2 = 1;
tfischer72 0:910a2d3aac71 21 wait(1.0);
tfischer72 0:910a2d3aac71 22 }
tfischer72 0:910a2d3aac71 23 if(c == '3') {
tfischer72 0:910a2d3aac71 24 myled3 = 1;
tfischer72 0:910a2d3aac71 25 wait(1.0);
tfischer72 0:910a2d3aac71 26 }
tfischer72 0:910a2d3aac71 27 if(c == '4') {
tfischer72 0:910a2d3aac71 28 myled4 = 1;
tfischer72 0:910a2d3aac71 29 wait(1.0);
tfischer72 0:910a2d3aac71 30 }
tfischer72 0:910a2d3aac71 31 pc.putc(c);
tfischer72 0:910a2d3aac71 32 myled1=0;
tfischer72 0:910a2d3aac71 33 myled2=0;
tfischer72 0:910a2d3aac71 34 myled3=0;
tfischer72 0:910a2d3aac71 35 myled4=0;
tfischer72 0:910a2d3aac71 36 }
tfischer72 0:910a2d3aac71 37 }
tfischer72 0:910a2d3aac71 38 }