Charles Tritt / Mbed 2 deprecated myBlink21

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
CSTritt
Date:
Sat Sep 11 23:36:43 2021 +0000
Parent:
1:9f6f3af9aaaa
Commit message:
My version of Blink for 2021.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 9f6f3af9aaaa -r 6427bc50123c main.cpp
--- a/main.cpp	Wed Sep 13 18:59:14 2017 +0000
+++ b/main.cpp	Sat Sep 11 23:36:43 2021 +0000
@@ -1,8 +1,8 @@
 /*
-  Blink
-  Turns on an LED on for one second, then off for one second, repeatedly.
- 
-  This example code is in the public domain.
+  Blink -   Turns on an LED on and off for, repeatedly.
+  Last Revised: 9/11/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.
@@ -11,24 +11,23 @@
 //  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);
-/*  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.
+float waitOn = 1.4f; // On time in seconds. All variables must be declared.
+float waitOff = 0.6f; // Off time in seconds. The f indicates float type.
+/*  
+    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.
+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.
-        wait(0.5);      // wait(x) will pause for a given number of seconds.
+        wait(waitOn);      // wait(x) will pause for a given number of seconds.
         board_LED = 0;  // Turn off LED by storing a 0 in board_LED.
-        wait(0.5);      // wait another 1/2 second.
+        wait(waitOff);      // wait another 1/2 second.
     }  // end of repeated actions  
 }  // end of main function
\ No newline at end of file