You can write text with this programm.
Fork of Minor_test_serial by
main.cpp@1:26ce7013f2c5, 2016-09-12 (annotated)
- Committer:
- JanderGilbers
- Date:
- Mon Sep 12 10:14:01 2016 +0000
- Revision:
- 1:26ce7013f2c5
- Parent:
- 0:c8f15874531b
- Child:
- 2:4ffe049e7231
It now prints the characters you press on your keyboard.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:c8f15874531b | 1 | #include "mbed.h" |
vsluiter | 0:c8f15874531b | 2 | #include "MODSERIAL.h" |
vsluiter | 0:c8f15874531b | 3 | |
vsluiter | 0:c8f15874531b | 4 | DigitalOut myled(LED_GREEN); |
vsluiter | 0:c8f15874531b | 5 | MODSERIAL pc(USBTX, USBRX); |
JanderGilbers | 1:26ce7013f2c5 | 6 | char c; |
vsluiter | 0:c8f15874531b | 7 | |
vsluiter | 0:c8f15874531b | 8 | int main() |
vsluiter | 0:c8f15874531b | 9 | { |
vsluiter | 0:c8f15874531b | 10 | int i = 0; |
vsluiter | 0:c8f15874531b | 11 | pc.baud(115200); |
vsluiter | 0:c8f15874531b | 12 | pc.printf("Hello World!\n"); |
vsluiter | 0:c8f15874531b | 13 | |
JanderGilbers | 1:26ce7013f2c5 | 14 | while(true){ |
JanderGilbers | 1:26ce7013f2c5 | 15 | { |
JanderGilbers | 1:26ce7013f2c5 | 16 | c = pc.getc(); |
JanderGilbers | 1:26ce7013f2c5 | 17 | pc.printf("%c", c); // print the value of variable i |
vsluiter | 0:c8f15874531b | 18 | i++; // increment the variable |
vsluiter | 0:c8f15874531b | 19 | myled = !myled; // toggle a led |
JanderGilbers | 1:26ce7013f2c5 | 20 | wait(0.1f); |
JanderGilbers | 1:26ce7013f2c5 | 21 | } |
vsluiter | 0:c8f15874531b | 22 | } |
vsluiter | 0:c8f15874531b | 23 | } |