Pages: [1]   Go Down
Author Topic: inconsistant results  (Read 585 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was trying out the code and instructions found at http://www.arduino.cc/en/Tutorial/Button to try to understand how the digital input works and I found that:

1) if I disconnect the V5 and GND cables of my breadboardand also disconnect pin 7, pin13 is off (this is expected)
2) with the same setup v5 and GND unplug, but then touching pin 7 quickly and removing the cable, pin13 goes on then off immediatly as expected, but I if do this +3 times consecutivly, then pin 13 goes on and stays on for a good 1 second (sometimes more)

why is this..?  :-/

I am a newbie..
« Last Edit: January 17, 2008, 12:16:53 am by gunfus » Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When a input isnt connected to anything and you try reading from it you will get any result.
Its called a 'floating' input.

What it reads depends on the current temperature, humidity, EMF and the phase of the moon. smiley-wink
Essentially its completely random.

To get reliable results you must have a pin connected to either VCC or GND at all times.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I added a short explanation of floating inputs to the tutorials.  Hopefully it should help other people in the future.
Logged

USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 452
Freeduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a way to set/unset the internal atmega168 pull-up resistors using software (Arduino prog language)?
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is there a way to set/unset the internal atmega168 pull-up resistors using software (Arduino prog language)?
Yes.

Code:
// example for pin 8
pinMode(8, INPUT);
digitalWrite(8, HIGH);       // turn on pullup resistor
// or
digitalWrite(8, LOW);       // turn off pullup resistor (default)

--Phil.
Logged

Pages: [1]   Go Up
Jump to: