int a=0;
void setup()
{
pinMode(A5,INPUT);
pinMode(13,OUTPUT);
}
void loop()
{
a = digitalRead(A5);
if(a == 1)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}
i connect 5v pin to A5pin through pushbutton.
when i press the button the led is glowing.
but when i release the button, the led was turning off only after 5 second
Use a digital pin as input and use a pullup resistor for the button.
EDIT: Also not that pin 13 is used by the internal LED and that it is used as clock signal for SPI. Maybe another pin would be better.
Use a digital pin as input
He already is.
The suggestion to use a pullup resistor for the input is a good one and the easiest way to do it is to use
pinMode(A5, INPUT_PULLUP);
and to change the circuit so that the input is taken to GND (ie LOW) when the button is pressed