First Steps

Hey
Im working at this sketch since many hours and dunno why it isnt work.
Can someone correct it pls?

"

int ledred = 10;
int ledgreen = 9;
int pins1 = 7;
int pins2 = 6;
int value = 0;

void setup ()
{
pinMode(ledred, OUTPUT);
pinMode(ledgreen, OUTPUT);
pinMode(pins1, INPUT);
pinMode(pins2, INPUT);
}
void loop()
{
value = digitalRead(pins1);
if (value == LOW)
{
digitalWrite(ledred, HIGH);
} else {
value = digitalRead(pins2);
if (value == LOW) {
digitalWrite(ledgreen, HIGH);
}
else
digitalWrite(ledred, LOW);
digitalWrite(ledgreen, LOW);
}

}

"
I hope you can help me

Im working at this sketch since many hours and dunno why it isnt work.

That code does something. You expect it to do something. Clearly, those two somethings are not the same thing.

What either of them is, though, is a mystery. You need to help us solve that mystery first.

ive got two buttons and one led . if I press button 1 the LED should make red light. If i press button 2 the LED should make green light. If I dont press the button the led shouldnt make a light.

That's half of he answer.
Now, tell us what happens.

unfortunally nothing but I dont know why other programs are working

How are the buttons wired?

 else digitalWrite(ledred, LOW); digitalWrite(ledgreen, LOW);

Are you missing some braces here?
The 'else' only makes the red LED conditional, but the green will always be turned off.

AWOL:

 else digitalWrite(ledred, LOW); digitalWrite(ledgreen, LOW);

Are you missing some braces here?
The 'else' only makes the red LED conditional, but the green will always be turned off.

how can i change this?

How are the buttons wired?

And how are the LEDs wired?

Right now, you could have hardware issues, software issues, or both.

Likely there are software issues. Please use the Tools + Auto Format function to straighten out the random indenting in your code, to make it easier to read.

Try a simple sketch that simply turns the two LEDs on. See if they both light up. If not, fix the LED wiring.

Then, another simple sketch that simply reads one switch state, and writes it to the serial monitor. Does the value change when you press the switch? Does it change back when you release the switch?

Djbryntrollx:
"
int ledred = 10;
int ledgreen = 9;
int pins1 = 7;
int pins2 = 6;
int value = 0;
"

What numbers i have to take? I just know that i have to take numbers between 0-13

What numbers i have to take?

For what purpose?

I just know that i have to take numbers between 0-13

You should not be using pins 0 and 1, so that you can use the serial port for debugging.

PaulS:

What numbers i have to take?

For what purpose?

how the board know that pins1 should be button 1? thats what i dont understand

how the board know that pins1 should be button 1? thats what i dont understand

You connect the switch to some pin. Then, you tell the program that the pin is an input pin, using the pinMode() function, and you read the state of that pin, using the digitalRead() function. Both of these functions have, as the first argument, the pin number.

That is how the board knows which pin goes with which switch or which LED. You tell it.

and where i can find out the pin number of the switch?

and where i can find out the pin number of the switch?

Follow the wire from the switch to the Arduino? Which pin does the wire go into?