Hello guys,
i was trying to read the digital values low and high on a arduino nano board and these value i was looked on a serial monitor but they always shows me 0(zero)low value.
i was already check my hardware that is ok i was check this state on a multimeter i was got the right values
on a multimeter but not get the values on board pin what was the issue is here i don't know .
below i was attached the sample code for the purpose of understanding Please look at once and tell me whenever and which position to be i was wrong?
Programm:
int ledPin = 13; // LED connected to digital pin 13
int interPin = 5; //pin d2 as input
int val = 0; // variable to store the read value
int overrange = 20;
int over = 0;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(interPin, INPUT); // sets the digital pin 5(d2)as input
pinMode(overrange, INPUT);
Serial.begin(9600);
}
void loop()
{
val = digitalRead(interPin); // read the input pin
delay(100);
Serial.println(val);
digitalWrite(ledPin, val); // sets the LED to the button's value
}
Best Regards,
seggi.
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
If your button is wired between Vcc and pin, do you use a pull-down resistor?
If your button is wired between Gnd and pin, do you use a pull-up resistor?
What happens if you remove the button and wire the pin directly to Vcc or Gnd?
i was already check my hardware that is ok i was check this state on a multimeter i was got the right values on a multimeter but not get the values on board pin
So you either have made a mistake checking it, or somehow you have blown that pin. Have you tested it on another pin?
Hi,
I think we need a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Thanks.. Tom... 
Hello guys,
i want to read the digital values on the digital pin D2. But the problem is whenever i am trying to read values and these values ate printed onto the serial monitor they always shows me the 0(Low value).
my Hardware connection is also seems the right i was already check the state or value on to the multimeter they are showed me right values of high(5v) and low(0v) .
But whenever i am trying on to the arduino nano they cant be able to gave me the data.
What is the problem is here i don't know right now please suggest me something or help me to resolve this issue.
Belowe i am posting the actual code .
#include<stdio.h>
int ledPin = 13; // LED connected to digital pin 13
int interPin = 5; //pin d2 as input
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(interPin, INPUT); // sets the digital pin 5(d2)as input
Serial.begin(9600);
}
void loop()
{
val = digitalRead(interPin); // read the input pin
delay(100);
Serial.println(val);
digitalWrite(ledPin, val); // sets the LED to the input's value
}
Best Regards,
seggi.
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
@seggi, please do not cross-post. Threads merged.
i want to read the digital values on the digital pin D2.
Then why is your code using the D5 pin?
int interPin = 5; //pin d2 as input
This code clearly uses pin 5 not pin 2 as your comment says.