FRDM-K64F Code Share / Mbed 2 deprecated Light_and_Temp_Control Featured

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
fedeedlp
Date:
Thu Aug 07 19:39:59 2014 +0000
Commit message:
First Commit

Changed in this revision

Servo.lib 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 8fa77db93e75 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Thu Aug 07 19:39:59 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 8fa77db93e75 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 07 19:39:59 2014 +0000
@@ -0,0 +1,56 @@
+/*This program monitoring the light and the temperature and send a serial command (if the user chose it) and turn on a light signal*/
+
+#include "mbed.h"
+#include "Servo.h"
+
+Servo Servo_Temp(D13);
+Servo Servo_Light(D14);
+AnalogIn temperature(A0);
+AnalogIn light(A1);
+DigitalOut temp_alert(D0);
+DigitalOut light_alert(D1);
+int i;
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main()
+{
+    temp_alert=0;
+    light_alert=0;
+    pc.printf("Press 'y' to receive commands or 'n' for not receive\n");
+    char mode = pc.getc();
+    while(1) {
+        if (temperature>5) { //High Temperature
+            i=0;
+            while(i<10) {
+                temp_alert=1;
+                wait(1);
+                temp_alert=0;
+                i++;
+            }
+            temp_alert=1;
+            Servo_Temp.position(0);
+            if(mode=='y')
+                pc.printf("High Temperature");
+
+        } else
+            temp_alert=0;
+        Servo_Temp.position(100);
+
+        if (light<1) { //Low Light
+            i=0;
+            while(i<10) {
+                light_alert=1;
+                wait(1);
+                light_alert=0;
+                i++;
+            }
+            light_alert=1;
+            Servo_Light.position(0);
+            if(mode=='y')
+                pc.printf("Low Light");
+        } else
+            light_alert=0;
+        Servo_Light.position(100);
+        wait(1);
+    }
+}
diff -r 000000000000 -r 8fa77db93e75 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Aug 07 19:39:59 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804
\ No newline at end of file