You can write text with this programm.

Dependencies:   MODSERIAL mbed

Fork of Minor_test_serial by First Last

Committer:
JanderGilbers
Date:
Mon Sep 12 10:34:25 2016 +0000
Revision:
2:4ffe049e7231
Parent:
1:26ce7013f2c5
RGB keyboard control;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsluiter 0:c8f15874531b 1 #include "mbed.h"
vsluiter 0:c8f15874531b 2 #include "MODSERIAL.h"
vsluiter 0:c8f15874531b 3
JanderGilbers 2:4ffe049e7231 4 DigitalOut grled(LED_GREEN);
JanderGilbers 2:4ffe049e7231 5 DigitalOut rdled(LED_RED);
JanderGilbers 2:4ffe049e7231 6 DigitalOut blled(LED_BLUE);
vsluiter 0:c8f15874531b 7 MODSERIAL pc(USBTX, USBRX);
JanderGilbers 1:26ce7013f2c5 8 char c;
JanderGilbers 2:4ffe049e7231 9 int Ticker;
JanderGilbers 2:4ffe049e7231 10
JanderGilbers 2:4ffe049e7231 11 void ticking(bool& a)
JanderGilbers 2:4ffe049e7231 12 {
JanderGilbers 2:4ffe049e7231 13 a = !a;
JanderGilbers 2:4ffe049e7231 14 }
vsluiter 0:c8f15874531b 15
vsluiter 0:c8f15874531b 16 int main()
vsluiter 0:c8f15874531b 17 {
vsluiter 0:c8f15874531b 18 int i = 0;
vsluiter 0:c8f15874531b 19 pc.baud(115200);
vsluiter 0:c8f15874531b 20 pc.printf("Hello World!\n");
vsluiter 0:c8f15874531b 21
JanderGilbers 1:26ce7013f2c5 22 while(true){
JanderGilbers 1:26ce7013f2c5 23 {
JanderGilbers 1:26ce7013f2c5 24 c = pc.getc();
JanderGilbers 1:26ce7013f2c5 25 pc.printf("%c", c); // print the value of variable i
JanderGilbers 2:4ffe049e7231 26 switch (c)
JanderGilbers 2:4ffe049e7231 27 {
JanderGilbers 2:4ffe049e7231 28 case 'r' :
JanderGilbers 2:4ffe049e7231 29 rdled = false;
JanderGilbers 2:4ffe049e7231 30 grled = true;
JanderGilbers 2:4ffe049e7231 31 blled = true;
JanderGilbers 2:4ffe049e7231 32 break;
JanderGilbers 2:4ffe049e7231 33 case 'b' :
JanderGilbers 2:4ffe049e7231 34 rdled = true;
JanderGilbers 2:4ffe049e7231 35 grled = true;
JanderGilbers 2:4ffe049e7231 36 blled = false;
JanderGilbers 2:4ffe049e7231 37 break;
JanderGilbers 2:4ffe049e7231 38 case 'g' :
JanderGilbers 2:4ffe049e7231 39 rdled = true;
JanderGilbers 2:4ffe049e7231 40 grled = false;
JanderGilbers 2:4ffe049e7231 41 blled = true;
JanderGilbers 2:4ffe049e7231 42 break;
JanderGilbers 2:4ffe049e7231 43 }
JanderGilbers 1:26ce7013f2c5 44 wait(0.1f);
JanderGilbers 1:26ce7013f2c5 45 }
vsluiter 0:c8f15874531b 46 }
vsluiter 0:c8f15874531b 47 }