If statements HELP

hello new to arduino
need help with an "if" statement at the end

current issue, arduino not returning ld2 to HIGH state

current code/issue:
if((ld1,LOW),(ld2,LOW)) digitalWrite(ld2,HIGH);

full code:

int p1=A0;
int p2=A1;
//calculated value
int RV1;
int RV2;
//piezo output
float pZ1;
float pZ2;
//LED's
int ld1=2;
int ld2=3;
//delaytime
int dt1=50;
int dt2=250;
//analog data read

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ld1, OUTPUT);
pinMode(ld2, OUTPUT);

digitalWrite(ld1,HIGH);
digitalWrite(ld2,HIGH);

pinMode(pZ1, INPUT);
pinMode(pZ2, INPUT);

}

void loop()
{
// put your main code here, to run repeatedly:

RV1=analogRead(p1);
pZ1=RV1;
Serial.print("piezo 1 val ");
Serial.println(pZ1);
if(pZ1<=1)
{
digitalWrite(ld1,LOW);
}
delay(dt1);

RV2=analogRead(p2);
pZ2=RV2;
Serial.print("piezo 2 val ");
Serial.println(pZ2);

if(pZ2>=1000)digitalWrite(ld2,LOW);
delay(dt1);
*if((ld1,LOW),(ld2,LOW)) digitalWrite(ld2,HIGH);*
delay(dt1);

}

Where did you find this syntax.

Tell us what it does.

.

I do not know what that is supposed to do. Bad syntax. Study the if reference.

maybe you intended

if(pZ2>=1000)  {
    digitalWrite(ld2,LOW);
    delay(dt1);
    digitalWrite(ld2,HIGH);
    delay(dt1);
}

It does nothing thats what i need help with lol

Have studied it and what i want is not mentioned within its vague description.

No i actually want ld2 to go HIGH if ld1 and ld2 are low. But i am not sure how to write that.

Also i have no idea what syntax is.
Sry still learning all of this code vernacular.

if( (digitalRead(ld1) == LOW) && (digitalRead(ld2) == LOW))  
{
     digitalWrite(ld2, HIGH);
}

There are a lot of good Arduino (C++) language tutorials out there.

C++ tutorial.

Google C++ syntax

Well, tell us what you want it to do ?

if (digitalRead(ld1) == LOW and digitalRead(ld2) == LOW)
   digitalWrite(ld2, HIGH);

is this what you want?

programming language syntax is the grammar, order of various parts of the language

below you correctly write an if statement which has a condition that that can be true or false

in the next case, the condition isn't valid and it's unclear what was intended

@groundFungus suggested the following which combines 2 conditions using a logical AND (&&)

ok im done trying to figure out this on my own. looking for help now.
how do i write
if (digitalRead(ld1) == LOW and digitalRead(ld2) == LOW and digitalRead(ld3) == LOW and digitalRead(ld4) ==HIGH)
{
digitalWrite(ld1,HIGH);
}
and here is where my question comes in...

**BUT IF
(digitalRead(ld1) == HIGH and digitalRead(ld2) == LOW and digitalRead(ld3) == LOW and digitalRead(ld4) ==HIGH)

and changes to
(digitalRead(ld1) == LOW and digitalRead(ld2) == LOW and digitalRead(ld3) == LOW and digitalRead(ld4) ==HIGH)
{
digitalWrite(ld2,HIGH);

More importantly why are you writing to an input?

int ld1=2;
int ld2=3;
int ld3=4;
int ld4=5;

pinMode(ld1, OUTPUT);
pinMode(ld2, OUTPUT);
pinMode(ld3, OUTPUT);
pinMode(ld4, OUTPUT);

I'm tired of 100 post threads. Kindly explain your project.

We got this, no use stukgling alone.

Google

Arduino state change detection

and you'll instantly find an Arduino article, and I think there is an example in the IDE.

Try getting things to happen with the transition of one button.

Then use the same idea to track all your buttons.

The states of all you buttons can be combined into a code that would be, for example, 0 to 15 for four buttons.

You can look for transitions between those coded values and do whatever, like if the the code went from 1001 to 0001 in binary.

If that makes no sense, just play with the state transition detection examples. You are a bit <-- see what I did there? out over your skis just now.

a7

You can write that exactly how you have it.

This is what confuses me. If you have these as outputs don't you already know you changed the outputs? In other words, if ld1 went from HIGH to LOW then YOU wrote a line of code to change it since it is an output!

You haven't yet asked a clear question.

attempting to build an interactive system that with 4 item. when an item is interacted with that item is removed all the way down to 1 item remaining. when only one item is remaining return 1 of the 3 removed items. except for the last removed item. trying to not have 1001-> 0001->1001->0001->1001(loop). would rather have 1001->0001-> then go to 0101 or 0011.