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.
Diff: main.cpp
- Revision:
- 107:61b9c99a4e27
- Parent:
- 105:ed03c03b353e
- Child:
- 108:eee3167b25b4
--- a/main.cpp Fri Nov 22 16:00:04 2019 +0000
+++ b/main.cpp Mon Sep 20 03:01:02 2021 +0000
@@ -1,23 +1,33 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2019 ARM Limited
- * SPDX-License-Identifier: Apache-2.0
- */
-
+/*
+ 21_myBlink_v5 - Turns on an LED on and off for, repeatedly.
+ Last Revised: 9/19/21 (v. 1.0)
+ Based on mbed example. Modified by Dr. C. S. Tritt. This example code is in
+ the public domain.
+*/
+// #include is a directive that "pastes" a file into your code.
+// Use this specific #include at the beginning of each mbed program.
+// mbed.h contains/points to the full definitions of our simple statements.
#include "mbed.h"
-#include "platform/mbed_thread.h"
-
-
-// Blinking rate in milliseconds
-#define BLINKING_RATE_MS 500
-
-
-int main()
-{
- // Initialise the digital pin LED1 as an output
- DigitalOut led(LED1);
-
- while (true) {
- led = !led;
- thread_sleep_for(BLINKING_RATE_MS);
- }
-}
+// Define the object board_LED to be a digital output connected to LED1,
+// which is the little green LED built into the Nucleo board.
+DigitalOut board_LED(LED1);
+const int WAIT_ON = 1400; // On time in seconds.
+const int WAIT_OFF = 600; // Off time in seconds.
+/*
+ The "main" function defines your main program -- it executes as soon as
+ you program the board. Functions can return (compute and give back) a
+ value. The main function could return an integer error code, so it begins
+ with int. Functions can also accept inputs. The main function cannot
+ however, so its round parentheses are empty.
+*/
+int main() { // This curly brace marks the beginning of the main function.
+ // while() will repeat a set of actions as long as the statement inside
+ // its round parentheses is true. 1 is the definition of true, so
+ // while(1) and while(true) repeat forever.
+ while(true) { // This curly brace marks the start of the repeated actions.
+ board_LED = 1; // Turn on LED by storing a 1 in board_LED.
+ ThisThread::sleep_for(WAIT_ON); // Int value in mS.
+ board_LED = 0; // Turn off LED by storing a 0 in board_LED.
+ ThisThread::sleep_for(WAIT_OFF); // Int value in mS.
+ } // end of repeated actions
+} // end of main function
\ No newline at end of file