AND / Mbed 2 deprecated handheld_with_solenoid

Dependencies:   mbed

co2.h

Committer:
christodoulos
Date:
2019-07-04
Revision:
1:af991edb6dc1
Parent:
0:958e045ea7d1

File content as of revision 1:af991edb6dc1:

#include "mbed.h"

Serial co2(D1,D0); //USED IN MAIN


int value;

int carbon()
{
    bool allow = false;
    char c;
    char co2_measure[5];
    int count=0;

    while(1) {
        c = co2.getc();
        if(c=='Z') {
            allow = true;
        }

        if(allow) {
            if(c>=48 && c<=57) {
                co2_measure[count]=c;
                count++;
            }
        
            if(count>=6) { //NOT SURE IF 5 OR 6
                value = ((co2_measure[0]-'0')*100000+co2_measure[1]-'0')*10000+(co2_measure[2]-'0')*1000+(co2_measure[3]-'0')*100; 
                count=0;
                allow=false;
                return value;
            }
        }
    }
}