![](/media/cache/profiles/493c8b3821e768713a4d1c5b1e7f5ad4.jpg.50x50_q85.png)
miniblip serial demo
Fork of HelloWorld by
main.cpp@2:8a14f4d5079b, 2015-11-26 (annotated)
- Committer:
- pighixxx
- Date:
- Thu Nov 26 09:30:25 2015 +0000
- Revision:
- 2:8a14f4d5079b
miniblip serial demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pighixxx | 2:8a14f4d5079b | 1 | // miniblip USB Serial |
pighixxx | 2:8a14f4d5079b | 2 | |
pighixxx | 2:8a14f4d5079b | 3 | #include "mbed.h" |
pighixxx | 2:8a14f4d5079b | 4 | |
pighixxx | 2:8a14f4d5079b | 5 | |
pighixxx | 2:8a14f4d5079b | 6 | unsigned int counter = 0; |
pighixxx | 2:8a14f4d5079b | 7 | Serial pc(USBTX, USBRX); |
pighixxx | 2:8a14f4d5079b | 8 | |
pighixxx | 2:8a14f4d5079b | 9 | void count() { |
pighixxx | 2:8a14f4d5079b | 10 | // Announce lifetime |
pighixxx | 2:8a14f4d5079b | 11 | pc.printf("mini blip is alive for %i seconds.\n", counter); |
pighixxx | 2:8a14f4d5079b | 12 | counter++; |
pighixxx | 2:8a14f4d5079b | 13 | } |
pighixxx | 2:8a14f4d5079b | 14 | |
pighixxx | 2:8a14f4d5079b | 15 | int main() { |
pighixxx | 2:8a14f4d5079b | 16 | // Turn off miniblip buzzer |
pighixxx | 2:8a14f4d5079b | 17 | PwmOut speaker(P0_8); |
pighixxx | 2:8a14f4d5079b | 18 | speaker=0.0; |
pighixxx | 2:8a14f4d5079b | 19 | pc.printf("Hello world!\n"); |
pighixxx | 2:8a14f4d5079b | 20 | while(true) { //Main loop |
pighixxx | 2:8a14f4d5079b | 21 | count(); |
pighixxx | 2:8a14f4d5079b | 22 | wait(1); |
pighixxx | 2:8a14f4d5079b | 23 | } |
pighixxx | 2:8a14f4d5079b | 24 | } |