Example showing comments.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mattshuman
Date:
Sat Aug 13 01:47:43 2016 +0000
Commit message:
Removed artifacts from source code.

Changed in this revision

Blinker.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r fbca7accb93b Blinker.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Blinker.h	Sat Aug 13 01:47:43 2016 +0000
@@ -0,0 +1,38 @@
+/*! Lab1TestAdvanced3
+ *  Used for advanced LED blinking with the FRDM-KL46Z.  This adds a .h file to leverage modularity and also provides an example of a proper commenting style.
+ * \author  Matthew Shuman
+ *
+ * \date    August 12th, 2016
+
+ * \bug     No bugs yet
+
+ * @code
+ * #include "mbed.h"
+ *
+ * outputLED may be r or g, frequency is in Hertz, and brightness can range between 0 and 1.
+ * void blink(output LED, frequency, brightness)
+ * {
+ * }
+ * @endcode
+ */
+ 
+#include "mbed.h"
+// this class file is a template on using .h files.
+class Blinker
+{
+public:
+    Blinker(void) {
+    };
+// class method to blink and LED based on the PwmOut class
+    void blink(PwmOut outputLED, float frequency, float brightness) {
+        outputLED.period(.001f);
+        outputLED = 1- brightness;
+        float duration = (1.0/frequency)/2;  //dividing by 2 lets the microcontroller wait for half of the period before changing the LED.
+        wait(duration);
+        outputLED = 1.0;  //LED is active low, so setting this to 1 turns off the LED.
+        wait(duration);
+    };
+
+private:
+    
+};
\ No newline at end of file
diff -r 000000000000 -r fbca7accb93b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 13 01:47:43 2016 +0000
@@ -0,0 +1,48 @@
+/*! Lab1TestAdvanced3
+ *  Used for advanced LED blinking with the FRDM-KL46Z.  This adds a .h file to leverage modularity and also provides an example of a proper commenting style.
+ * \author  Matthew Shuman
+ *
+ * \date    August 12th, 2016
+
+ * \bug     No bugs yet
+
+ * @code
+ * #include "mbed.h"
+ * #include "Blinker.h"
+ *
+ * PwmOut r(LED_RED);
+ *
+ * int main()
+ * {
+ *   Blinker myBlinker;
+ *   while(1) {
+ *      for(float i = 0; i < 5; i++) {  //Blink the LED 5 times
+ *          myBlinker.blink(r or g, frequency in Hertz, % brightness (0 - 1.00) );
+ *      }
+ *   }//end of while
+ * }//end of main
+ * @endcode
+ */
+
+#include "mbed.h"
+#include "Blinker.h"
+
+//This creates Pulse Width Modulated outputs, r and g, and connects them to the red and green LED.
+PwmOut r(LED_RED);
+PwmOut g(LED_GREEN);
+
+int main()
+{
+    // constructs member of new Blinker class, myBlinker
+    Blinker myBlinker;
+    while(1) {
+        for(float i = 0; i < 5; i++) {  //Blink the LED 5 times
+            // blinks the green LED at 2 Hz, with 75% brightness
+            myBlinker.blink(g, 2, .75);
+        }
+        for(float i = 0; i < 10; i++) {  //Blink the LED 10 times
+            // blinks the red LED at 4 Hz, with 15% brightness
+            myBlinker.blink(r, 4, .15);
+        }
+    }//end of while
+}//end of main
diff -r 000000000000 -r fbca7accb93b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 13 01:47:43 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b0220dba8be7
\ No newline at end of file