![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
main.cpp@1:fcea0d9117c5, 2011-10-17 (annotated)
- Committer:
- gbeardall
- Date:
- Mon Oct 17 10:41:21 2011 +0000
- Revision:
- 1:fcea0d9117c5
- Parent:
- 0:4ec8695c9c5b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gbeardall | 0:4ec8695c9c5b | 1 | /* |
gbeardall | 0:4ec8695c9c5b | 2 | * flash1: main.cpp - test program |
gbeardall | 0:4ec8695c9c5b | 3 | * |
gbeardall | 0:4ec8695c9c5b | 4 | */ |
gbeardall | 0:4ec8695c9c5b | 5 | |
gbeardall | 0:4ec8695c9c5b | 6 | #include "mbed.h" |
gbeardall | 0:4ec8695c9c5b | 7 | |
gbeardall | 0:4ec8695c9c5b | 8 | DigitalOut led1(LED1); |
gbeardall | 0:4ec8695c9c5b | 9 | DigitalOut led2(LED2); |
gbeardall | 0:4ec8695c9c5b | 10 | DigitalOut led3(LED3); |
gbeardall | 0:4ec8695c9c5b | 11 | DigitalOut led4(LED4); |
gbeardall | 0:4ec8695c9c5b | 12 | |
gbeardall | 0:4ec8695c9c5b | 13 | Serial pc(USBTX,USBRX); |
gbeardall | 0:4ec8695c9c5b | 14 | |
gbeardall | 0:4ec8695c9c5b | 15 | Ticker tick2; |
gbeardall | 0:4ec8695c9c5b | 16 | Ticker tick3; |
gbeardall | 0:4ec8695c9c5b | 17 | Ticker tick4; |
gbeardall | 0:4ec8695c9c5b | 18 | |
gbeardall | 0:4ec8695c9c5b | 19 | // --------------------------------------------------------------------------- |
gbeardall | 0:4ec8695c9c5b | 20 | |
gbeardall | 0:4ec8695c9c5b | 21 | void flash2() { |
gbeardall | 0:4ec8695c9c5b | 22 | led2 = !led2; |
gbeardall | 0:4ec8695c9c5b | 23 | } |
gbeardall | 0:4ec8695c9c5b | 24 | |
gbeardall | 0:4ec8695c9c5b | 25 | void flash3() { |
gbeardall | 0:4ec8695c9c5b | 26 | led3 = !led3; |
gbeardall | 0:4ec8695c9c5b | 27 | } |
gbeardall | 0:4ec8695c9c5b | 28 | |
gbeardall | 0:4ec8695c9c5b | 29 | void flash4() { |
gbeardall | 0:4ec8695c9c5b | 30 | led4 = !led4; |
gbeardall | 0:4ec8695c9c5b | 31 | } |
gbeardall | 0:4ec8695c9c5b | 32 | |
gbeardall | 0:4ec8695c9c5b | 33 | // --------------------------------------------------------------------------- |
gbeardall | 0:4ec8695c9c5b | 34 | |
gbeardall | 0:4ec8695c9c5b | 35 | int main() { |
gbeardall | 0:4ec8695c9c5b | 36 | |
gbeardall | 0:4ec8695c9c5b | 37 | led2 = 1; |
gbeardall | 0:4ec8695c9c5b | 38 | tick2.attach(&flash2, 0.5); |
gbeardall | 0:4ec8695c9c5b | 39 | |
gbeardall | 0:4ec8695c9c5b | 40 | led3 = 1; |
gbeardall | 0:4ec8695c9c5b | 41 | tick3.attach(&flash3, 1.0); |
gbeardall | 0:4ec8695c9c5b | 42 | |
gbeardall | 0:4ec8695c9c5b | 43 | led4 = 1; |
gbeardall | 0:4ec8695c9c5b | 44 | tick4.attach(&flash4, 2.0); |
gbeardall | 0:4ec8695c9c5b | 45 | |
gbeardall | 1:fcea0d9117c5 | 46 | pc.printf("\n\rStart: flash1\n\r"); |
gbeardall | 0:4ec8695c9c5b | 47 | |
gbeardall | 0:4ec8695c9c5b | 48 | while (1) { |
gbeardall | 0:4ec8695c9c5b | 49 | led1 = 1; |
gbeardall | 0:4ec8695c9c5b | 50 | wait(0.25); |
gbeardall | 0:4ec8695c9c5b | 51 | led1 = 0; |
gbeardall | 0:4ec8695c9c5b | 52 | wait(0.25); |
gbeardall | 0:4ec8695c9c5b | 53 | |
gbeardall | 0:4ec8695c9c5b | 54 | pc.printf("."); |
gbeardall | 0:4ec8695c9c5b | 55 | |
gbeardall | 0:4ec8695c9c5b | 56 | } // while |
gbeardall | 0:4ec8695c9c5b | 57 | |
gbeardall | 0:4ec8695c9c5b | 58 | } // main |
gbeardall | 1:fcea0d9117c5 | 59 | |
gbeardall | 1:fcea0d9117c5 | 60 | // --------------------------------------------------------------------------- |
gbeardall | 1:fcea0d9117c5 | 61 |