analog reference

hello all,
I am using atmega328(without arduino,but programmed using arduino) in my project where in I am checking input from sensor on analog pin.
if it is HIGH necessary action is taken.
But even when no input is given by sensor,atmega shows HIGH signal.
Is this related to analog reference?

It's probably just noise, and you need a pull-down to force it low.... Just because a pin isn't deliberately high, doesn't mean it's actually low.

Actually I am getting HIGH when it should return LOW.

RaHuLL:
hello all,
I am using atmega328(without arduino,but programmed using arduino) in my project where in I am checking input from sensor on analog pin.
if it is HIGH necessary action is taken.
But even when no input is given by sensor,atmega shows HIGH signal.

What sensor, what circuit, what code? My crystal ball isn't working today.

RaHuLL:
Is this related to analog reference?

Very unlikely.

RaHuLL:
Actually I am getting HIGH when it should return LOW.

But how do you know it should be low?- when it's not getting any input there's no way of telling what it "should" be.

As fungus says, post more detail....

I am doing this as my college project.
I am using sim900 module along with PIR sensor.

void loop()
{
    val1 = digitalRead(inputPin1); // read input value from PIR
    if (val1 == HIGH) { // check if the input is HIGH
      mySerial.print("ATD +919*********;");//dial the number
      delay(100);
      mySerial.println();
  } 
  else {
  }
}

now this code calls me even when nothing is detected by PIR.
And for power,I am using 3.7V battery.

Why all the talk of analogue reference when all you are doing is a digital read?

Have you measured the input on the pin you are using?

You need to post ALL the code so we can see what you are doing.

I am doing this as my college project.

Then you should have access to test equipment.

val1 = digitalRead(inputPin1); // read input value from PIR
    if (val1 == HIGH) { // check if the input is HIGH
      mySerial.print("ATD +919*********;");//dial the number

I should point out that loop is executed thousands of times a second, so you are going to be dialing that number an awful lot.

I should point out that loop is executed thousands of times a second, so you are going to be dialing that number an awful lot.

How if condition will be satisfied every time?

now this code calls me even when nothing is detected by PIR.

Which PIR?
Where is your code?

How if condition will be satisfied every time?

Yes if you hold down the button for say one second it will be executed about 1000 times.
All it does is check if the button is down, it does not check that it has just gone down. In other words it checks for a level not an edge.

You need to read this:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

I tried example given at Arduino Playground - PIRsense where in inbuilt pull up is used.
But still i am getting continues calls.

But still i am getting continues calls.

...and we're still waiting for details of the PIR.

PIR used is given at: How to use Pyroelectric ("Passive") Infrared Sensors (PIR)

RaHuLL:
I tried example given at Arduino Playground - PIRsense where in inbuilt pull up is used.
But still i am getting continues calls.

Post your new code.

Did you address what I said in reply #7?

...checking input from sensor on analog pin.
yet
val1 = digitalRead(inputPin1);

You're checking an analog pin with a digitalRead? Am I missing something... shouldn't it be an analogRead?

Also, if indeed using digitalRead, shouldn't you define the pin as an input with pinMode(inputPin1, INPUT)?