Offline
Newbie
Karma: 0
Posts: 16
|
 |
« on: February 10, 2013, 06:53:50 am » |
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
Edison Member
Karma: 34
Posts: 1705
|
 |
« Reply #1 on: February 10, 2013, 07:02:07 am » |
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
|
IT Crowd: Roy... "Have you tried turning it off and on again?" Moss.. "Have you tried forcing an unexpected reboot?"
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 16
|
 |
« Reply #2 on: February 10, 2013, 07:23:09 am » |
Actually I am getting HIGH when it should return LOW.
|
|
|
|
|
Logged
|
|
|
|
|
Valencia, Spain
Online
Edison Member
Karma: 65
Posts: 2272
|
 |
« Reply #3 on: February 10, 2013, 07:27:26 am » |
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
|
|
|
|
|
Johannesburg UTC+2
Offline
Edison Member
Karma: 34
Posts: 1705
|
 |
« Reply #4 on: February 10, 2013, 07:37:51 am » |
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
|
IT Crowd: Roy... "Have you tried turning it off and on again?" Moss.. "Have you tried forcing an unexpected reboot?"
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 16
|
 |
« Reply #5 on: February 10, 2013, 12:44:25 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25566
Solder is electric glue
|
 |
« Reply #6 on: February 10, 2013, 12:49:04 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #7 on: February 10, 2013, 03:15:00 pm » |
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
Newbie
Karma: 0
Posts: 16
|
 |
« Reply #8 on: February 11, 2013, 09:17:40 am » |
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
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #9 on: February 11, 2013, 09:55:39 am » |
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.
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25566
Solder is electric glue
|
 |
« Reply #10 on: February 11, 2013, 10:40:13 am » |
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
Newbie
Karma: 0
Posts: 16
|
 |
« Reply #11 on: February 12, 2013, 10:39:16 am » |
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
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #12 on: February 12, 2013, 10:42:47 am » |
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.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 16
|
 |
« Reply #13 on: February 12, 2013, 11:49:23 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #14 on: February 12, 2013, 03:36:45 pm » |
Post your new code. Did you address what I said in reply #7?
|
|
|
|
|
Logged
|
|
|
|
|
|