Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@2:5a073ef49b21, 2013-03-30 (annotated)
- Committer:
- lotfi_baghli
- Date:
- Sat Mar 30 10:30:38 2013 +0000
- Revision:
- 2:5a073ef49b21
- Parent:
- 1:a9798dd70dbf
- Child:
- 3:cd558875d654
T1Interrupt + Serial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lotfi_baghli | 0:d9b6ce6032fc | 1 | #include "mbed.h" |
lotfi_baghli | 2:5a073ef49b21 | 2 | |
lotfi_baghli | 2:5a073ef49b21 | 3 | DigitalOut myled(LED1); |
lotfi_baghli | 0:d9b6ce6032fc | 4 | DigitalOut led2(LED2); |
lotfi_baghli | 2:5a073ef49b21 | 5 | DigitalIn Rx433(p20); |
lotfi_baghli | 2:5a073ef49b21 | 6 | Serial pc(USBTX, USBRX); |
lotfi_baghli | 2:5a073ef49b21 | 7 | Ticker T1; |
lotfi_baghli | 2:5a073ef49b21 | 8 | |
lotfi_baghli | 2:5a073ef49b21 | 9 | unsigned int i; |
lotfi_baghli | 1:a9798dd70dbf | 10 | |
lotfi_baghli | 2:5a073ef49b21 | 11 | void T1Interrupt() { |
lotfi_baghli | 2:5a073ef49b21 | 12 | //myled = 1- myled; |
lotfi_baghli | 2:5a073ef49b21 | 13 | i++; |
lotfi_baghli | 2:5a073ef49b21 | 14 | if ((i&1)==1) myled = 1; |
lotfi_baghli | 2:5a073ef49b21 | 15 | else myled = 0; |
lotfi_baghli | 2:5a073ef49b21 | 16 | } |
lotfi_baghli | 2:5a073ef49b21 | 17 | |
lotfi_baghli | 0:d9b6ce6032fc | 18 | int main() { |
lotfi_baghli | 2:5a073ef49b21 | 19 | i=0; |
lotfi_baghli | 2:5a073ef49b21 | 20 | pc.baud(115200); |
lotfi_baghli | 2:5a073ef49b21 | 21 | // T1.attach_us(&T1Interrupt,500000); // setup T1 interrupt |
lotfi_baghli | 2:5a073ef49b21 | 22 | T1.attach(&T1Interrupt,2.0); // setup T1 interrupt |
lotfi_baghli | 0:d9b6ce6032fc | 23 | while(1) { |
lotfi_baghli | 2:5a073ef49b21 | 24 | led2 = !led2; |
lotfi_baghli | 2:5a073ef49b21 | 25 | wait(0.5); |
lotfi_baghli | 2:5a073ef49b21 | 26 | |
lotfi_baghli | 2:5a073ef49b21 | 27 | // i=(Rx433==1); |
lotfi_baghli | 2:5a073ef49b21 | 28 | // pc.printf("rx= %d ", i); |
lotfi_baghli | 2:5a073ef49b21 | 29 | pc.printf("%d", i); |
lotfi_baghli | 2:5a073ef49b21 | 30 | // i++; |
lotfi_baghli | 0:d9b6ce6032fc | 31 | } |
lotfi_baghli | 2:5a073ef49b21 | 32 | } |