#include<SoftwareSerial.h>#defineContinueMode0#definePollingMode1constint rxPin =2;constint txPin =3;SoftwareSerial Serial1(rxPin, txPin);voidsetup(){Serial.begin(9600);Serial1.begin(9600);//AGSM sensor module connectiondelay(1000);#ifContinueModeSerial.println("Continuous Mode");#elseif PollingModeSerial.println("Polling Mode");#endifSerial.println("Serial, Conc.(PPB), Temp.(C), Rh(%), Adc.(Counts), Temp.(Counts), Rh(%Counts)");#ifContinueModeSerial1.write('c');Serial1.write('\r');#endif}voidloop(){#ifPollingModeSerial1.write('\r');delay(1000);#elsedelay(100);#endif while (Serial1.available()) // read from AGSM port, send to Serial port to interupt continuous output send 'c''/r' without line ending, may have to send more than once.
{int inByte =Serial1.read();Serial.write(inByte); }}