Code not working?!

int a = 53;
int b = 13;

void setup() {
// put your setup code here, to run once:
pinMode(a, INPUT);
pinMode(b, OUTPUT);

void loop() {

if (a == HIGH)
digitalWrite(b, HIGH);
{ digitalWrite(b, LOW);

This is my code...i want to make pin 13 turns On,when pin 53 is get 5V but it's not working.The controler is Mega 2560. I will be glad if someone can help me.Thanks!

  if (a == HIGH)This is testing the value of a, which is a pin number, not the state of the pin.

You need to use digitalRead(a); to determine the state of the pin.

how to do this ? :slight_smile:

Start by looking at the Button example in the IDE

how to do this ? :slight_smile:

As you seem to know how to use digitalWrite() it does not seem to require a great deal of thinking to make some progress with digitalRead().

And, as a very last resort, you could always read the Reference page.

Don't expect people to tell you stuff that is already conveniently available to you with a few strokes of Google.