How to combine two different sensor sketches to one complete sketch for a complete circuit that attaches to one Arduino Uno?
Sharp Dust Sensor
int measurePin = A0; // Connect dust sensor to Arduino A0 pin
int ledPower = D8; // Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
}
void loop(){
digitalWrite(ledPower,LOW); // power on the LED
delayMicroseconds(samplingTime);
voMeasured = analogRead(measurePin); // read the dust value
delayMicroseconds(deltaTime);
digitalWrite(ledPower,HIGH); // turn the LED off
delayMicroseconds(sleepTime);
// 0 - 5V mapped to 0 - 1023 integer values
// recover voltage
calcVoltage = voMeasured * (5.0 / 1024.0);
dustDensity = 0.17 * calcVoltage - 0.1;
Serial.print("Raw Signal Value (0-1023): ");
Serial.print(voMeasured);
Serial.print(" - Voltage: ");
Serial.print(calcVoltage);
Serial.print(" - Dust Density: ");
Serial.println(dustDensity); // unit: mg/m3
delay(1000);
}
MQ-135 Sensor
int airquality = A2;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A2);
Serial.print("Air Quality = ");
Serial.print(sensorValue);
Serial.print("*PPM");
Serial.println();
delay(1000);
}
combine 2 sensors
has multiple meanings .......... please ask a detailed question