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@1:97d5e01d84c5, 2019-03-09 (annotated)
- Committer:
- kemalicecek
- Date:
- Sat Mar 09 00:16:38 2019 +0000
- Revision:
- 1:97d5e01d84c5
- Parent:
- 0:016968e54f88
- Child:
- 2:d93965299d43
added button press
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kemalicecek | 0:016968e54f88 | 1 | #include "mbed.h" |
kemalicecek | 0:016968e54f88 | 2 | |
kemalicecek | 0:016968e54f88 | 3 | Serial pc(USBTX, USBRX); // tx, rx |
kemalicecek | 0:016968e54f88 | 4 | |
kemalicecek | 0:016968e54f88 | 5 | InterruptIn mybutton(USER_BUTTON); |
kemalicecek | 0:016968e54f88 | 6 | DigitalOut myled(LED1); |
kemalicecek | 0:016968e54f88 | 7 | DigitalOut extled(PC_0); |
kemalicecek | 0:016968e54f88 | 8 | |
kemalicecek | 1:97d5e01d84c5 | 9 | bool mode = 0; |
kemalicecek | 1:97d5e01d84c5 | 10 | |
kemalicecek | 1:97d5e01d84c5 | 11 | void pressed() |
kemalicecek | 1:97d5e01d84c5 | 12 | { |
kemalicecek | 1:97d5e01d84c5 | 13 | mode = !mode; //press the button for changing the loop |
kemalicecek | 1:97d5e01d84c5 | 14 | } |
kemalicecek | 1:97d5e01d84c5 | 15 | |
kemalicecek | 0:016968e54f88 | 16 | int main(){ |
kemalicecek | 1:97d5e01d84c5 | 17 | mybutton.fall(&pressed); |
kemalicecek | 0:016968e54f88 | 18 | while (1){ |
kemalicecek | 0:016968e54f88 | 19 | if (mode == 0){ |
kemalicecek | 0:016968e54f88 | 20 | pc.printf("short\r\n"); |
kemalicecek | 0:016968e54f88 | 21 | wait(1); |
kemalicecek | 0:016968e54f88 | 22 | } |
kemalicecek | 0:016968e54f88 | 23 | else{ |
kemalicecek | 0:016968e54f88 | 24 | pc.printf("long\r\n"); |
kemalicecek | 0:016968e54f88 | 25 | wait(1); |
kemalicecek | 0:016968e54f88 | 26 | } |
kemalicecek | 0:016968e54f88 | 27 | } |
kemalicecek | 0:016968e54f88 | 28 | } |