gas sensor how to add a second sensor

I have a sketch of the gas sensor, and please help me how to add a second sensor
I use RGB LEDs
green-ok
red gas
blue carbon monoxide

int sensorPin = 0;
int redled = 2;
int greenled = 4;
int gas = 0;

void setup() {
pinMode(greenled, OUTPUT);
pinMode(redled, OUTPUT);
Serial.begin(9600);
}
void loop() {
gas = analogRead(sensorPin);
if (gas >= 500)
{
noTone(10);
digitalWrite(redled, LOW);
digitalWrite(greenled, HIGH);
}

else if (gas > 300)
{
tone(10, 740, 200);
}

else
{
tone(10, 440, 200);
digitalWrite(redled, HIGH);
digitalWrite(greenled, LOW);

}
Serial.println(gas);
delay(1000);
}

do you want to have LED's for each sensor of do the LED's represent any problem ?

start with copying the lines adding 1 to everything

gas = analogRead(sensorPin); // first sensor
gas1 = analogRead(sensorPin1); //second sensor

if you only want the existing LED's you can just change the IF statment to look at 1 OR the other.

if (gas1 >= 500) || (gas >= 500) {

this way, if either gas or gas1 is over 500, it will light the LED's

wanted to order 2 sensor was to pin 1
and blue LED pin 6

Try next sketch... red led is on if is a danger situation, green led is on of gas is ok, blue led is on of carbon monoxide is ok.. gas sensor is at A0 pin & carbon monoxide is at pin A1 pin...

gregor36_2gassensor_ver1m0.ino (1.28 KB)

niq_ro:
Try next sketch... red led is on if is a danger situation, green led is on of gas is ok, blue led is on of carbon monoxide is ok.. gas sensor is at A0 pin & carbon monoxide is at pin A1 pin...

not work
connect the pin A1
blocks the effects of the sensor at A0
that is, the buzzer does not work
red LED is not lit
blue LED is lit continuously

after signal on A1
buzzer gives a signal
blue LED is lit continuously

try changed sketch (just put a delay command, maybe is ok)..

PS: second sensor not block first.. after first sensor is not a delay to see (time for change is to short)....

I hope now is ok..

gregor36_2gassensor_ver1m1.ino (1.29 KB)

instead of calling for the tone output in each IF statement, change to tone1 and tone2 can call for sound separately.

if gas1 >= 300
tone1 = 1

...

if gas2 >= 300
tone2 =1

...

if (tone1 ==1 || tone2==1 ){
sound horn

niq_ro:
try changed sketch (just put a delay command, maybe is ok)..

PS: second sensor not block first.. after first sensor is not a delay to see (time for change is to short)....

I hope now is ok..

sensors ok
buzzer ok

blue LED constantly lit

Gregor, try corrected sketch...

gregor36_2gassensor_ver1m1m.ino (1.29 KB)

niq_ro:
Gregor, try corrected sketch...

yes ok