Ive had a look at the reference home page but cant find what I need, I want to write a code where one function followed by the other in sequence triggers another function. The two functions will not happen at the same they will happen one after the other. So in theory what i need is
if (LDRpin1 < 50 THEN LDRpin2 < 50) // If LDR1 falls below a value of 50 followed by LDR2 falling below a value of 50
{
digitalWrite(LEDpin1, HIGH) // if both happen in sequence light up LEDpin1
You haven't really posted enough of your code to give you a very useful answer...
There's no built-in 'THEN' feature as you're describing. You'll either need to track everything via state variables, or nest conditionals (if you know the two events will happen at the same time).
What does THEN signify in terms of timing?
i.e.
Do you mean that both LDRpin1 < 50 and LDRpin2 < 50 at the same time?
Do you mean that any time in the next __ seconds after LDRpin1 < 50 when LDRpin2 < 50?
Do you mean any point ever, regardless of how long between pin1 and pin2?
Do you want the program to be able to do other things while waiting on pin2?
Or, should we deadlock until pin2 < 50?
int LDRpin1 = 0; //LDR1 in analog pin 0
int LDRpin2 = 1;
you posted earlier, you've got the problem that you're confusing the pin name with the value that you should be reading from that pin with an analogRead.
However, as has been pointed out, there is no concept of "after" or "then", and the test in your code(if they were syntactically correct) would be executed just a few microseconds apart.