main.cpp 588 Bytes
#include "mbed.h"
#include "PollutionDevice.h"

DigitalOut led1(LED1);
Serial pc(USBTX, USBRX, PollutionDevice::baud);
Serial uart(D8, D2, PollutionDevice::baud);

int main()
{
    pc.printf("starting...\n\n");
    PollutionDevice pollutionDevice(&uart);
    
    while(1) {
        if(pollutionDevice.canBeRead()){ 
            pollutionDevice.read();
            pc.printf("PM1.0: %d ug/m3\nPM2.5: %d ug/m3\nPM10: %d ug/m3\n\n", pollutionDevice.getPM01(), pollutionDevice.getPM2_5(), pollutionDevice.getPM10());
                         
            led1 = !led1;
        }
    }
}