complete program
This commit is contained in:
parent
703f5e6d1a
commit
69895ad824
1 changed files with 39 additions and 37 deletions
76
src/main.cpp
76
src/main.cpp
|
@ -10,53 +10,55 @@
|
||||||
#define MEASURE_DELAY 1000
|
#define MEASURE_DELAY 1000
|
||||||
#define NOISE_DELAY 100
|
#define NOISE_DELAY 100
|
||||||
|
|
||||||
|
const int maxCount = 10;
|
||||||
|
int count = 0;
|
||||||
|
bool noise = false;
|
||||||
|
bool noiseActive = false;
|
||||||
|
|
||||||
|
float ppm;
|
||||||
|
|
||||||
MQ135 co2_sensor(PIN_MQ135);
|
MQ135 co2_sensor(PIN_MQ135);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
// co2_sensor.setR0(1000.);
|
co2_sensor.setR0(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printValues(float ppm, float temp, float humidity);
|
void printValues(float ppm, float temp, float humidity);
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
float value = co2_sensor.getCO2();
|
if (count >= maxCount || count < 0) {
|
||||||
Serial.print("co2: ");
|
ppm = co2_sensor.getCO2();
|
||||||
Serial.println(value);
|
|
||||||
delay(2000);
|
|
||||||
// if (count >= maxCount || count < 0) {
|
|
||||||
// float temp = bme.readTemperature();
|
|
||||||
// float humidity = bme.readHumidity();
|
|
||||||
// ppm = co2_sensor.getCorrectedPPM(temp, humidity);
|
|
||||||
|
|
||||||
// count = 0;
|
count = 0;
|
||||||
// if (ppm < 1000) {
|
if (ppm < 1000) {
|
||||||
// digitalWrite(PIN_LED_GREEN, 1);
|
noiseActive = false;
|
||||||
// digitalWrite(PIN_LED_YELLOW, 0);
|
digitalWrite(PIN_LED_GREEN, 1);
|
||||||
// digitalWrite(PIN_LED_RED, 0);
|
digitalWrite(PIN_LED_YELLOW, 0);
|
||||||
// }
|
digitalWrite(PIN_LED_RED, 0);
|
||||||
// else if (ppm <= 2000) {
|
}
|
||||||
// digitalWrite(PIN_LED_GREEN, 0);
|
else if (ppm <= 2000) {
|
||||||
// digitalWrite(PIN_LED_YELLOW, 1);
|
noiseActive = false;
|
||||||
// digitalWrite(PIN_LED_RED, 0);
|
digitalWrite(PIN_LED_GREEN, 0);
|
||||||
// }
|
digitalWrite(PIN_LED_YELLOW, 1);
|
||||||
// else {
|
digitalWrite(PIN_LED_RED, 0);
|
||||||
// digitalWrite(PIN_LED_GREEN, 0);
|
}
|
||||||
// digitalWrite(PIN_LED_YELLOW, 0);
|
else {
|
||||||
// digitalWrite(PIN_LED_RED, 1);
|
noiseActive = true;
|
||||||
// }
|
digitalWrite(PIN_LED_GREEN, 0);
|
||||||
|
digitalWrite(PIN_LED_YELLOW, 0);
|
||||||
|
digitalWrite(PIN_LED_RED, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// printValues(ppm, temp, humidity);
|
if (noiseActive) {
|
||||||
// }
|
noise = !noise;
|
||||||
|
digitalWrite(PIN_NOISE, noise);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
digitalWrite(PIN_NOISE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// if (ppm > 2000) {
|
delay(NOISE_DELAY);
|
||||||
// noise = !noise;
|
count++;
|
||||||
// digitalWrite(PIN_NOISE, noise);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// digitalWrite(PIN_NOISE, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// delay(NOISE_DELAY);
|
|
||||||
// count++;
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue