quiz1_1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
shih775007
Date:
Wed Mar 01 10:09:07 2017 +0000
Commit message:
quiz1_1

Changed in this revision

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 01 10:09:07 2017 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+ 
+#define BREATHE_PERIOD         4500    // ms
+#define INHALE_PERIOD          (BREATHE_PERIOD / 4)
+#define EXHALE_PERIOD          (BREATHE_PERIOD / 2)
+#define HOLD_PERIOD            (BREATHE_PERIOD / 8)
+ 
+ 
+//BusOut leds(LED1, LED2, LED3, LED4);
+PwmOut led(D6);
+ 
+int main() {
+    float brightness;
+    
+    while(1) {
+        for (int i = 0; i <= 32; i++) {
+            brightness = i * i / (float)(32 * 32);
+            led = brightness;
+            wait_ms(INHALE_PERIOD / 32);
+        }
+        
+        wait_ms(HOLD_PERIOD);
+        
+        for (int i = 0; i <= 32; i++) {
+            brightness = 1- (i * i / (float)(32 * 32));
+            led = brightness;
+            wait_ms(EXHALE_PERIOD / 32);
+        }
+        
+        wait_ms(HOLD_PERIOD);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 01 10:09:07 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974
\ No newline at end of file