final

Dependencies:   KS0108 WIZnet_Library mbed

Fork of bigthingRec by rohan gala

Revision:
4:a4ec8ea99d70
Parent:
3:0ee289161a2a
Child:
5:c0f61c21e78c
diff -r 0ee289161a2a -r a4ec8ea99d70 main.cpp
--- a/main.cpp	Tue Mar 15 11:38:05 2016 +0000
+++ b/main.cpp	Thu May 12 06:22:14 2016 +0000
@@ -3,7 +3,7 @@
 #include "WIZnetInterface.h"
 
 unsigned char MAC_Addr[6] = {0x90,0x08,0xDC,0x12,0x07,0x07};
-
+PwmOut led(PTA12);
 char* Update_Key = "L055HRYFCBL1LTM2";
 char* ServerIP = "api.thingspeak.com";
 int Count = 15;
@@ -17,26 +17,27 @@
 char buff[]={'\0'};
 
 AnalogIn ax(PTC1);
+AnalogIn ain(PTC2);
 
 float luxm(void)
 {
-AnalogIn ain(PTC2);
+
 
 float vr=0;
-   /*float vr=0,lr=0;
-float vol[12]={0.36,0.61,0.8,0.9,1.23,1.45,1.81,2.06,2.62,2.81,3.02,3.25};
-float lux[12]={27000,20000,16000,11000,4000,1500,833,578,201,104,40,23};
+float lr=0;
+float vol[13]={0,1.1,1.23,1.3,1.45,1.6,1.81,2.06,2.31,2.62,2.81,3.02,3.1};
+float lux[13]={27000,20000,16000,11000,7000,4000,1500,833,578,201,104,40,23};
 
 int i;
 float m=0;
-*/
+
 vr=ain*3.3;
-/*
+
 for(i=0; vr> vol[i];i++);
 m = ((lux[i]-lux[i+1])/(vol[i]-vol[i+1]));
 lr=lux[i+1]+(m*(vr-(vol[i+1])));
-*/
-return vr;
+
+return lr;
 }
 
 uint8_t val;
@@ -84,14 +85,25 @@
      char buffer[300];
     int ret_t;
     char http_cmd[256]; 
+    
+     int l=luxm(); 
+     
+     
+    
+    
     while(val==0x00)
     {
+      float x=ain;
+      led=x;
+      
       if(micro.readable()) 
       {
         val=(micro.getc());
         if(val == 0x01)
-        {      
-          pc.printf("%.2f ",luxm());
+        {  
+              
+          pc.printf("%.2f ",l);
+          
           
     
     sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field1= %.2f HTTP/1.0\n\n",luxm());
@@ -109,7 +121,7 @@
            pc.printf("%.2f ",ax*3.3);
            
     
-    sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field2= %.2f HTTP/1.0\n\n",ax*3.3);
+    sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field2= %.2f HTTP/1.0\n\n",ax*3.3*17);
     printf("Running - %s\r\n",http_cmd);
     sock.send_all(http_cmd, sizeof(http_cmd)-1);