MSOE EE2905 / Mbed 2 deprecated Blink

Dependencies:   mbed

Fork of Blink by Sheila Ross

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002   Blink
00003   Turns on an LED on for one second, then off for one second, repeatedly.
00004  
00005   This example code is in the public domain.
00006 */
00007  
00008 //  #include is a directive that "pastes" a file into your code.
00009 //  Use this specific #include at the beginning of each mbed program.
00010 //  mbed.h contains/points to the full definitions of our simple statements.
00011 
00012 #include "mbed.h"
00013  
00014 //  Define the object board_LED to be a digital output connected to LED1,
00015 //  which is the little green LED on the Nucleo board.
00016 
00017 DigitalOut board_LED(LED1);
00018 
00019 /*  The "main" function defines your main program--it executes as soon as
00020     you program the board.
00021  
00022     Functions can return (compute and give back) a value.  The main function
00023     could return an integer error code, so it begins with int.
00024     
00025     Functions can also accept inputs.  The main function cannot however, so
00026     its round parentheses are empty.
00027 */
00028       
00029 int main() {   // This curly brace marks the beginning of the main function.
00030 
00031     // while() will repeat a set of actions as long as the statement inside
00032     // its round parentheses is true.  1 is the definition of true, so
00033     // while(1) repeats forever.
00034     
00035     while(1) {   // This curly brace marks the beginning of the repeated actions.
00036     
00037         board_LED = 1;  // Turn on LED by storing a 1 in board_LED.
00038         wait(0.5);      // wait() will pause for a given number of seconds.
00039         board_LED = 0;  // Turn off LED by storing a 0 in board_LED.
00040         wait(0.5);      // wait another 1/2 second.
00041     
00042     }  // end of repeated actions
00043     
00044 }  // end of main function