SWJTU
/
main_1
test
main.cpp@0:2ab98cdf79ea, 2020-05-15 (annotated)
- Committer:
- chentao88
- Date:
- Fri May 15 01:56:09 2020 +0000
- Revision:
- 0:2ab98cdf79ea
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chentao88 | 0:2ab98cdf79ea | 1 | #include "mbed.h" |
chentao88 | 0:2ab98cdf79ea | 2 | |
chentao88 | 0:2ab98cdf79ea | 3 | InterruptIn button(SW2); |
chentao88 | 0:2ab98cdf79ea | 4 | DigitalOut led1(LED_RED); |
chentao88 | 0:2ab98cdf79ea | 5 | DigitalOut led2(LED_GREEN); |
chentao88 | 0:2ab98cdf79ea | 6 | DigitalOut led3(LED_BLUE); |
chentao88 | 0:2ab98cdf79ea | 7 | DigitalOut flash(LED4); |
chentao88 | 0:2ab98cdf79ea | 8 | |
chentao88 | 0:2ab98cdf79ea | 9 | void flip() { |
chentao88 | 0:2ab98cdf79ea | 10 | led1 = !led1; |
chentao88 | 0:2ab98cdf79ea | 11 | led2 = !led2; |
chentao88 | 0:2ab98cdf79ea | 12 | led3 = !led3; |
chentao88 | 0:2ab98cdf79ea | 13 | } |
chentao88 | 0:2ab98cdf79ea | 14 | |
chentao88 | 0:2ab98cdf79ea | 15 | int main() { |
chentao88 | 0:2ab98cdf79ea | 16 | //button.rise(&flip); // attach the address of the flip function to the rising edge |
chentao88 | 0:2ab98cdf79ea | 17 | while(1) { // wait around, interrupts will interrupt this! |
chentao88 | 0:2ab98cdf79ea | 18 | //led1 = 0; |
chentao88 | 0:2ab98cdf79ea | 19 | //led2 = 0; |
chentao88 | 0:2ab98cdf79ea | 20 | //led3 = 0; |
chentao88 | 0:2ab98cdf79ea | 21 | //while(button){ |
chentao88 | 0:2ab98cdf79ea | 22 | flash = !flash; |
chentao88 | 0:2ab98cdf79ea | 23 | //wait(0.25); |
chentao88 | 0:2ab98cdf79ea | 24 | //flip(); |
chentao88 | 0:2ab98cdf79ea | 25 | //} |
chentao88 | 0:2ab98cdf79ea | 26 | } |
chentao88 | 0:2ab98cdf79ea | 27 | } |