FRA221_2016 / Mbed 2 deprecated FRA221_P12code2

Dependencies:   BH1750 DHT mbed

Files at this revision

API Documentation at this revision

Comitter:
netlike
Date:
Wed Dec 07 04:11:12 2016 +0000
Commit message:
code

Changed in this revision

BH1750.lib Show annotated file Show diff for this revision Revisions of this file
DHT.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 e61f8c63b956 BH1750.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BH1750.lib	Wed Dec 07 04:11:12 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/vrabec/code/BH1750/#58ee8a917618
diff -r 000000000000 -r e61f8c63b956 DHT.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT.lib	Wed Dec 07 04:11:12 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Wimpie/code/DHT/#9b5b3200688f
diff -r 000000000000 -r e61f8c63b956 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 07 04:11:12 2016 +0000
@@ -0,0 +1,113 @@
+#include "mbed.h"
+#include "BH1750.h"
+#include "DHT.h"
+DHT sensor(D4,SEN11301P);
+DigitalOut ledout(D8);
+PwmOut ledin1(D10);
+PwmOut ledin2(D11);
+DigitalOut motor(D12);
+BH1750 lightSensor(I2C_SDA, I2C_SCL);
+Serial blue(PC_6, D9);
+Serial pc(D1, D0);
+
+int i = 0,user = 0,x = 0,y = 0,err;
+char light[4],humidity[4];
+float f1,light_new,humidity_new;
+int check = 0;
+char mm = 'x';
+double light_v = 0.5;
+
+int main()
+{
+
+    lightSensor.init();
+    ledin1 = light_v;
+    ledin2 = light_v;
+    while(true) {
+        while(check == 0) {
+            pc.printf("check=0");
+            if(blue.readable()){
+                mm = blue.getc();
+            }
+            if (lightSensor.readIntesity() <= 100) {
+                ledout = 1;
+            } else {
+                ledout =0;
+            }
+            err = sensor.readData();
+            if (err == 0) {
+                if (sensor.ReadHumidity() == 2) {
+                    motor = 1;
+                } else {
+                    motor =0;
+                }
+            } else {
+                printf("\r\nErr %i \n",err);
+            }
+            if (mm == 'i') {
+                check = 1;
+            }
+        }
+        pc.printf("****************\n");
+        for (i = 0 ; i <= 3 ; i++)  {
+            humidity[i] = '\0';
+        }
+        for (i = 0 ; i <= 3 ; i++)  {
+            light[i] = '\0';
+        }
+        if(mm == 'x') {
+            mm = blue.getc();
+            if (mm == 'i') {
+                check = 1;
+            }
+        }
+        pc.printf("c now = %c\n",mm);
+        if (check == 1) {
+            light_new = lightSensor.readIntesity()/5000;
+            humidity_new = sensor.ReadHumidity()/3;
+            sprintf(light,"%.2f",light_new);
+            sprintf(humidity,"%.2f",humidity_new);
+            if(mm == 'a') {
+                pc.printf("a getting\n");
+                for(i=0; i<=3; i++) {
+                    blue.printf("%c",humidity[i]);
+                }
+                pc.printf("a send\n");
+            }
+            if(mm == 'b') {
+                pc.printf("b send\n");
+                for(i=0; i<=3; i++) {
+                    blue.printf("%c",light[i]);
+                }
+                pc.printf("b send\n");
+            }
+            if(mm == '7')   {
+                motor = 1;
+            }
+            if(mm == '4')   {
+                motor = 0;
+            }
+            if(mm == '9')   {
+                ledout = 1;
+            }
+            if(mm == '6')   {
+                ledout = 0;
+            }
+            if(mm == '8')   {
+                light_v = light_v + 0.05;
+                ledin1 = light_v;
+                ledin2 = light_v;
+            }
+            if(mm == '5')   {
+                light_v = light_v - 0.05;
+                ledin1 = light_v;
+                ledin2 = light_v;
+            }
+            if(mm == 'o') {
+                check = 0;
+            }
+            mm = 'x';
+        }
+
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r e61f8c63b956 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 07 04:11:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file