Nick Zhao
/
Lab3Part3
4180 Lab 3 part 3
Revision 1:46cfe79bd861, committed 2019-10-07
- Comitter:
- TCNoodleshop
- Date:
- Mon Oct 07 02:38:49 2019 +0000
- Parent:
- 0:5014bf742e9b
- Commit message:
- Lab 3 Part 3
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Feb 14 14:30:22 2013 +0000 +++ b/main.cpp Mon Oct 07 02:38:49 2019 +0000 @@ -3,18 +3,39 @@ Ticker flipper; DigitalOut led1(LED1); DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); +int counter = 0; +Serial pc(USBTX, USBRX); void flip() { - led2 = !led2; + led1 = !led1; + counter++; + pc.printf("%d\n\r", counter); + if(counter == 8) + { + led4 = !led4; + counter = 0; + } + if(counter % 4 == 0) + { + led3 = !led3; + } + if(counter % 2 == 0) + { + led2 = !led2; + } } int main() { - led2 = 1; - flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds) + led1 = 0; + led2 = 0; + led3 = 0; + led4 = 0; + flipper.attach(&flip, 1.0); // the address of the function to be attached (flip) and the interval (2 seconds) // spin in a main loop. flipper will interrupt it to call flip while(1) { - led1 = !led1; wait(0.2); } } \ No newline at end of file
--- a/mbed.bld Thu Feb 14 14:30:22 2013 +0000 +++ b/mbed.bld Mon Oct 07 02:38:49 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file