Need help, I am new with arduino.
I would like to do this. Everytime the ls1 (main switch) is HIGH. I would like it to do 2 logic check then output accordingly.
- ls1 HIGH, waite 200 millisecond, check ls2, if ls2 is LOW, then turn on led1 for 10 seconds.
- ls1 HIGH, and stay HIGH more then 3000 millisecond, then turn on led1 for 5 seconds.
These 2 logic applies at the start of ls1 is HIGH.
below are the code I tried to write but its not doing what I want. new with C programming.
/*
*/
int ls1= 13; // Main Switch
int ls2=7; // Roller
int led1=2; // LED Light 1 output
// the setup routine runs once when you press reset:
void setup()
{
pinMode(ls1, INPUT);
pinMode(ls2, INPUT);
pinMode(led1, OUTPUT);
}
void loop() {
{
if (digitalRead(ls1) == HIGH)
{
delay(200);
if (digitalRead(ls2) == LOW)
{
digitalWrite(led1, HIGH);
delay(10000);
digitalWrite(led1, LOW);
}
}
else
{
digitalWrite(led1, LOW);
}
}
{
if (digitalRead(ls1) == HIGH)
{
delay(3000);
if (digitalRead(ls1) == HIGH)
{
digitalWrite(led1, HIGH);
delay(5000);
digitalWrite(led1, LOW);
}
}
else
{
digitalWrite(led1, LOW);
}
}
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.