Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: co2.h
- Revision:
- 0:958e045ea7d1
- Child:
- 1:9e66f21600f3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/co2.h Fri Mar 22 10:31:21 2019 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" + +Serial co2(D1,D0); + + +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>=5) { + value = ((co2_measure[1]-'0')*100000+co2_measure[2]-'0')*10000+(co2_measure[3]-'0')*1000+(co2_measure[4]-'0')*100; + count=0; + allow=false; + return value; + } + } + } +} +