I would like to know how to modify the code listed below to proceed only if two conditions are met. For example both voltage and light to be present before continuing to the next part of the loop. Maybe a double IF statement? or an IF & AND statement?
I am a novice coder with limited understanding so any assistance would be appreciated.
Thanks,
Code is listed below:
int light;
int volt;
void setup()
{
pinMode(13, OUTPUT); // put your setup code here, to run once:
pinMode(7, OUTPUT);
Serial.begin(9600);
}
void loop()
{
light = analogRead(A0); // put your main code here, to run repeatedly:
volt = analogRead (A4);
//*********************
if (light < 700)
{
digitalWrite(13, HIGH); // LED on:
digitalWrite(7, HIGH); // Relay on:
}
else
{
digitalWrite(13, LOW); //LED off:
digitalWrite(7, HIGH);
}
//*********************
if (light > 700)
{
digitalWrite(13, LOW);
delay(900000); //15 minute delay:
}
else
{
digitalWrite(13, HIGH);
}
//*********************
if (volt < 500)
{
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
}
else
{
digitalWrite(7, LOW);
delay(14400000); //4hr delay for battery recharge:
}
//*********************
if (volt > 500)
{
digitalWrite(7, LOW);
digitalWrite(13, LOW);
}
else
{
digitalWrite(7, HIGH);
}
//*********************
Serial.println(light);
delay(100);
} //END of loop()