const int analogInPin = A0;
const int ledPin = 17;
const int lightPin = 2;
const int ledPin2 = 14;
const int soundPin = 3;
const int ledPin3 = 15;
int lightValue = 0;
int sensorValue = 0;
int soundState = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(lightPin, INPUT);
pinMode(ledPin3, OUTPUT);
pinMode(soundPin, INPUT);
}
void loop() {
light();
sound();
gas();
}
void gas(){
sensorValue = analogRead(analogInPin);
if (sensorValue >= 200)
{
digitalWrite(ledPin, HIGH);
delay(10000);
digitalWrite(ledPin, LOW);
}
}
void light(){
lightValue = digitalRead(lightPin);
if (lightValue == HIGH) {
digitalWrite(ledPin2, HIGH);
delay(10000);
digitalWrite(ledPin2, LOW);
}
}
void sound(){
soundState = digitalRead(soundPin);
if (soundState == LOW) {
digitalWrite(ledPin3, HIGH);
delay(10000);
digitalWrite(ledPin3, LOW);
}
}
}
Here is what I did and it is working but when light is HIGH and ledPin2 is HIGH the other functions are not working or when gas is HIGH the other not work. They work one after another. How can i make them work together? Should i remove all the delays?