using if else statement

i need to know.. how to program switch one of a LED shield for the following condition.

if switch is ON(HIGH) this case should have to execute

void loop()
{
digitalWrite(5, HIGH);
delay(500);
deigitalWriye(5,LOW);
}

otherwise there will not be any output.

Have you tried anything yet? An if statement is one of the simplest of lines of code. If you have never seen one, try looking at a couple of C++ tutorials.

At least give it a try first.

i am new to all this and i was continously trying but didnt got anything.
i am working on Roboduino board.

Post your best attempt.

int x=2;
void setup()
{
pinMode(13,OUTPUT);
pinMode(2,INPUT);
}
void loop()
{
if(x==LOW)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}

but it is still not working.

OK, so you set x = 2 and then test if it is LOW (which is defined as 1). It will never be 1 because you told it to be 2 and never told it to be anything else.

Are you wanting to test the state of pin 2? Then you need to do a digitalRead.

if(digitalRead(x) == LOW)

state pin 2 is connected to the switch
and i just want to glow the led of roboduino board i.e. pin13 to glow when i pressed the switch.

faizkhan_1:
state pin 2 is connected to the switch
and i just want to glow the led of roboduino board i.e. pin13 to glow when i pressed the switch.

SO you don't want to react to the pin number being 2, you want to react to pin 2 being pulled to ground.

digitalRead is your friend. See response 7.

Perhaps you should take a tour through the reference page and a few of the examples and try to learn the basics of how to program an Arduino. This is all dead simple stuff. If it is really giving you fits and you're not willing to go read the documentation then you should probably sell your board to someone and take up another hobby.

brother..
this is the very first day of me with the introduction of arduino, thats why i dont know much.
i am learning it by myself and with ur help. i understand that my questions are so lame and boring for you.
but thanks a lot because ur suggestion really works.

faizkhan_1:
brother..
this is the very first day of me with the introduction of arduino, thats why i dont know much.
i am learning it by myself and with ur help. i understand that my questions are so lame and boring for you.
but thanks a lot because ur suggestion really works.

It's not that the questions are lame or boring. It is that it is obvious from the questions that you haven't read any of the documentation or even tried to learn this on your own. That is what is annoying. I don't mind helping, but you have to be willing to put in at least some small effort.

okay...
tell me or give me some link through which i can learn even the basics.

Look at the top of the page. See the links? Home, Buy, Download, Products, Learning, Forum, Support, Blog...

You see those. One of them looks like a pretty damn obvious place to start "Learning" about Arduino.