Nick Zhao
/
Lab3Part3
4180 Lab 3 part 3
main.cpp
- Committer:
- TCNoodleshop
- Date:
- 2019-10-07
- Revision:
- 1:46cfe79bd861
- Parent:
- 0:5014bf742e9b
File content as of revision 1:46cfe79bd861:
#include "mbed.h" Ticker flipper; DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); int counter = 0; Serial pc(USBTX, USBRX); void flip() { 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() { 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) { wait(0.2); } }