final
Dependencies: KS0108 WIZnet_Library mbed
Fork of bigthingRec by
Revision 6:6744a42b8824, committed 2016-07-27
- Comitter:
- rohangala
- Date:
- Wed Jul 27 08:31:49 2016 +0000
- Parent:
- 5:c0f61c21e78c
- Commit message:
- enjoy
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c0f61c21e78c -r 6744a42b8824 main.cpp --- a/main.cpp Fri May 20 18:30:52 2016 +0000 +++ b/main.cpp Wed Jul 27 08:31:49 2016 +0000 @@ -21,7 +21,7 @@ BusOut SevSeg1(PTD4,PTA12,PTA4,PTA5); -//BusOut SevSeg2(PTC8,PTC9,PTA13,PTD5); +BusOut SevSeg2(PTC8,PTC9,PTA13,PTD5); //DigitalOut toutb(PTA1); PwmOut ledout(LED1); @@ -38,14 +38,15 @@ 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]))); + 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 lr; } -uint8_t val; + +uint8_t val,val1; int main() { @@ -104,11 +105,11 @@ int j=0; while(1) { - + - while(val==0x00) + do { - for(i=j;i<20;i++) + for(i=j;i<60;i++) { float l=ain; float t=ax; @@ -116,14 +117,23 @@ ledout=1.0-l; if(l>=0 && l<0.25) - SevSeg1 = 0x01; - else if (l>=0.25 && l<0.5) - SevSeg1 = 0x03 ; - else if (l>=0.5 && l<0.75) + SevSeg1 = 0x00; + else if (l>=0.25 && l<0.50) + SevSeg1 = 0x01 ; + else if (l>=0.50 && l<0.75) + SevSeg1 = 0x03; + else if (l>=0.75 && l<=1.0) SevSeg1 = 0x07; - else if (l>=0.75 && l<=1.0) - SevSeg1 = 0x00; + + if(t<0.5050) + SevSeg2 = 0x00; + else if (t>=0.5050 && t<0.5070) + SevSeg2 = 0x01 ; + else if (t>=0.5070) + SevSeg2 = 0x03; + + if(micro.readable()) { val=(micro.getc()); @@ -135,7 +145,23 @@ wait(1); } - + TCPSocketConnection sock; + do + { + sock.connect("api.thingspeak.com", 80); + if(sock.is_connected()) + { + pc.printf("Socket Connected\n\r"); + val1=0x00; + } + else + { + pc.printf("Socket NoT Connected\n\r"); + val1=0xff; + } + + }while(val1==0xff); + if(val == 0x00) { pc.printf("%.2f ",luxm()); @@ -149,9 +175,9 @@ printf("Received %d chars from server:\n%s\r\n", ret_t, buffer); - pc.printf("%.2f ",ax*3.3); + pc.printf("%.2f ",ax*3.3*17); - sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field2= %.2f HTTP/1.0\n\n",ax*3.3*17); + sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field2= %.4f HTTP/1.0\n\n",ax*3.3*17/2); printf("Running - %s\r\n",http_cmd); sock.send_all(http_cmd, sizeof(http_cmd)-1); @@ -177,9 +203,9 @@ else if(val == 0x02) { - pc.printf("%.2f ",ax*3.3); + pc.printf("%.2f ",ax*3.3*17); - sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field2= %.2f HTTP/1.0\n\n",ax*3.3*17); + sprintf(http_cmd,"GET /update?key=L055HRYFCBL1LTM2&field2= %.4f HTTP/1.0\n\n",ax*3.3*17/2); printf("Running - %s\r\n",http_cmd); sock.send_all(http_cmd, sizeof(http_cmd)-1); @@ -188,7 +214,7 @@ printf("Received %d chars from server:\n%s\r\n", ret_t, buffer); val=0x00; } - } + }while(val==0x00); }