/////////////////////////////////// // // lab2_base project // // created 7/8/21 by tj // rev 0 // /////////////////////////////////// // // Base program for Lab2 // // This codes flashes an external LED on and off // and prints on or off to the console // // The external LED is connected to D4 // // Inputs: none // Outputs: external LED // ///////////////////////////////////////////// #include "mbed.h" #include // only needed when printing #define T_WAIT 2000000 // in us // Global HARDWARE Objects // create the LED object tied to D4 DigitalOut MyLED(D4); int main(void){ setbuf(stdout, NULL); // disable buffering when printing // splash printf("\n\nlab2_base\n"); printf("Using Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); // Initialize LED MyLED.write(0); // start with LED off // print header printf("LED value\n"); // run an infinite loop while(1){ // flash the LED and print to the terminal printf("off\n"); MyLED.write(0); wait_us(T_WAIT); printf("on\n"); MyLED.write(1); wait_us(T_WAIT); }// end while return 0; }// end main