AND / Mbed 2 deprecated handheld_with_solenoid

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers co2.h Source File

co2.h

00001 #include "mbed.h"
00002 
00003 Serial co2(D1,D0); //USED IN MAIN
00004 
00005 
00006 int value;
00007 
00008 int carbon()
00009 {
00010     bool allow = false;
00011     char c;
00012     char co2_measure[5];
00013     int count=0;
00014 
00015     while(1) {
00016         c = co2.getc();
00017         if(c=='Z') {
00018             allow = true;
00019         }
00020 
00021         if(allow) {
00022             if(c>=48 && c<=57) {
00023                 co2_measure[count]=c;
00024                 count++;
00025             }
00026         
00027             if(count>=6) { //NOT SURE IF 5 OR 6
00028                 value = ((co2_measure[0]-'0')*100000+co2_measure[1]-'0')*10000+(co2_measure[2]-'0')*1000+(co2_measure[3]-'0')*100; 
00029                 count=0;
00030                 allow=false;
00031                 return value;
00032             }
00033         }
00034     }
00035 }
00036