Min-ji Song / httpServer-WIZwiki-W7500

Dependencies:   Air_Quality DHT SDFileSystem Servo WIZnetInterface httpServer mbed-src

Fork of httpServer-WIZwiki-W7500 by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
M_J
Date:
Fri Aug 21 05:13:49 2015 +0000
Parent:
19:e2b03f4e2c7e
Commit message:
finish ^o^

Changed in this revision

httpServer.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
diff -r e2b03f4e2c7e -r 3b473e577885 httpServer.lib
--- a/httpServer.lib	Wed Aug 19 16:28:07 2015 +0000
+++ b/httpServer.lib	Fri Aug 21 05:13:49 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/WIZnet/code/httpServer/#859187375533
+https://developer.mbed.org/users/M_J/code/httpServer/#b2d8ac343302
diff -r e2b03f4e2c7e -r 3b473e577885 main.cpp
--- a/main.cpp	Wed Aug 19 16:28:07 2015 +0000
+++ b/main.cpp	Fri Aug 21 05:13:49 2015 +0000
@@ -13,17 +13,20 @@
 extern int lumi_val;
 extern int cel_val;
 extern int touch_val;
+extern int control;
 
-DHT sensor(D4, DHT11);
-InterruptIn motion(D5);
+DHT sensor(D8, DHT11);
+InterruptIn motion(D9);
 AnalogIn luminance(A1);
-InterruptIn event(D2);  // touch
+InterruptIn event(D10);  // touch
 Servo myservo(D14);  // touch servo 
 
 DigitalOut led_R(LED1);
 DigitalOut led_G(LED2);
 DigitalOut led_B(LED3);
 
+DigitalOut vol_in(A5);
+
 #ifdef TARGET_WIZWIKI_W7500
     //Choose one of file system.
     SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
@@ -71,14 +74,76 @@
     else
     i=0;
 }
+
+void sensor_5() {
+        
+        int rd_sensor = 0;  // when rd_sensor = 0, sensor is ready to read the data.
+        float hum = 0.0f;
+        float cel = 0.0f;
+        vol_in = 0;
+    
+        //DHT sensor
+        rd_sensor = sensor.readData();
+        if (0 == rd_sensor) {
+            hum = sensor.ReadHumidity();
+            cel = sensor.ReadTemperature(CELCIUS);
+            
+            printf("1. Humidity : %4.2f\r\n\n", hum);
+            wait(0.3);
+            printf("2. Temperature in Celcius : %2.2f\r\n\n", cel);
+            wait(0.3); }
+        else
+            printf("1,2. Error! : %d\r\n\n", rd_sensor);
+        
+        // motion    
+        if(motion_detected) {
+            motion_detected = 0;
+
+            printf("3. Something move!\r\n\r\n");
+            wait(0.3);
+            }
+        
+        // luminance    
+        printf("4. Luminance: %f\r\n\r\n", luminance.read());
+        //printf(" + lumi_val = %d\r\n\r\n", lumi_val);
+        
+        if(lumi_val == 0) {
+            led_R=1; led_G=1; led_B=1;} // led off
+        
+        else {     
+            if(luminance.read()<=0.1){
+                led_R=0; led_G=0; led_B=0;} // white LED on
+        
+            else if(0.1<=luminance.read()&&luminance.read()<=0.3){
+                led_R=0; led_G=0; led_B=1;} // yellow LED on
+            
+            else{
+                led_R=1; led_G=1; led_B=1;} // led off
+        }
+        
+        if(control == 1) {
+            if(cel_val == 0)
+                vol_in = 0;
+            else if(cel_val == 1)
+                vol_in = 1; }
+        else {
+            if(cel < 34)
+                vol_in = 0;
+            else if(cel >= 34)
+                vol_in = 1; }
+            
+
+        wait(1);
+}
+
  
  
 int main()
-{
+{    /*
     int rd_sensor = 0;  // when rd_sensor = 0, sensor is ready to read the data.
     float hum = 0.0f;
-    float cel = 0.0f;
-    
+    float cel = 0.0f;  */
+     
     HTTPFsRequestHandler::mount("/local/", "/");
     svr.addHandler<HTTPFsRequestHandler>("/");
  
@@ -122,9 +187,16 @@
     
     while(1) {
         svr.poll();
+        sensor_5();
         
-        wait(0.3);
+        if(control == 0) {
+            while (1)
+                sensor_5();
+        }
+        wait(1);
         
+    
+        /*
         //DHT sensor
         rd_sensor = sensor.readData();
         if (0 == rd_sensor) {
@@ -163,7 +235,7 @@
             
             else{
                 led_R=1; led_G=1; led_B=1;} // led off
-        }   
-        wait(1);
+        }  */ 
+        //wait(1);
     }
 }
\ No newline at end of file