Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@1:9f6f3af9aaaa, 2017-09-13 (annotated)
- Committer:
- CSTritt
- Date:
- Wed Sep 13 18:59:14 2017 +0000
- Revision:
- 1:9f6f3af9aaaa
- Parent:
- 0:293359e38af0
- Child:
- 2:1f9267d3f3f4
Initial copy version. Trying to get this associated with my account.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rossatmsoe | 0:293359e38af0 | 1 | /* |
rossatmsoe | 0:293359e38af0 | 2 | Blink |
rossatmsoe | 0:293359e38af0 | 3 | Turns on an LED on for one second, then off for one second, repeatedly. |
rossatmsoe | 0:293359e38af0 | 4 | |
rossatmsoe | 0:293359e38af0 | 5 | This example code is in the public domain. |
rossatmsoe | 0:293359e38af0 | 6 | */ |
rossatmsoe | 0:293359e38af0 | 7 | // #include is a directive that "pastes" a file into your code. |
rossatmsoe | 0:293359e38af0 | 8 | // Use this specific #include at the beginning of each mbed program. |
rossatmsoe | 0:293359e38af0 | 9 | // mbed.h contains/points to the full definitions of our simple statements. |
rossatmsoe | 0:293359e38af0 | 10 | #include "mbed.h" |
rossatmsoe | 0:293359e38af0 | 11 | // Define the object board_LED to be a digital output connected to LED1, |
CSTritt | 1:9f6f3af9aaaa | 12 | // which is the little green LED built into the Nucleo board. |
rossatmsoe | 0:293359e38af0 | 13 | DigitalOut board_LED(LED1); |
CSTritt | 1:9f6f3af9aaaa | 14 | /* The "main" function defines your main program -- it executes as soon as |
rossatmsoe | 0:293359e38af0 | 15 | you program the board. |
rossatmsoe | 0:293359e38af0 | 16 | |
rossatmsoe | 0:293359e38af0 | 17 | Functions can return (compute and give back) a value. The main function |
rossatmsoe | 0:293359e38af0 | 18 | could return an integer error code, so it begins with int. |
rossatmsoe | 0:293359e38af0 | 19 | |
rossatmsoe | 0:293359e38af0 | 20 | Functions can also accept inputs. The main function cannot however, so |
rossatmsoe | 0:293359e38af0 | 21 | its round parentheses are empty. |
CSTritt | 1:9f6f3af9aaaa | 22 | */ |
rossatmsoe | 0:293359e38af0 | 23 | int main() { // This curly brace marks the beginning of the main function. |
rossatmsoe | 0:293359e38af0 | 24 | // while() will repeat a set of actions as long as the statement inside |
CSTritt | 1:9f6f3af9aaaa | 25 | // its round parentheses is true. 1 is the definition of true, so |
CSTritt | 1:9f6f3af9aaaa | 26 | // while(1) and while(true) repeat forever. |
CSTritt | 1:9f6f3af9aaaa | 27 | while(true) { // This curly brace marks the start of the repeated actions. |
rossatmsoe | 0:293359e38af0 | 28 | |
rossatmsoe | 0:293359e38af0 | 29 | board_LED = 1; // Turn on LED by storing a 1 in board_LED. |
CSTritt | 1:9f6f3af9aaaa | 30 | wait(0.5); // wait(x) will pause for a given number of seconds. |
rossatmsoe | 0:293359e38af0 | 31 | board_LED = 0; // Turn off LED by storing a 0 in board_LED. |
rossatmsoe | 0:293359e38af0 | 32 | wait(0.5); // wait another 1/2 second. |
CSTritt | 1:9f6f3af9aaaa | 33 | } // end of repeated actions |
rossatmsoe | 0:293359e38af0 | 34 | } // end of main function |