Pages: [1] 2   Go Down
Author Topic: analog reference  (Read 1307 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3840
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually I am getting HIGH when it should return LOW.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Is this related to analog reference?

Very unlikely.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3840
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am doing this as my college project.
I am using sim900 module along with PIR sensor.
Code:
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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Quote
I am doing this as my college project.
Then you should have access to test equipment.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25769
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
now this code calls me even when nothing is detected by PIR.
Which PIR?
Where is your code?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried example given at http://playground.arduino.cc/Code/PIRsense where in inbuilt pull up is used.
But still i am getting continues calls.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25769
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But still i am getting continues calls.
...and we're still waiting for details of the PIR.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PIR used is given at: http://www.ladyada.net/learn/sensors/pir.html
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried example given at http://playground.arduino.cc/Code/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?
Logged

Pages: [1] 2   Go Up
Jump to: