Go Down

Topic: inconsistant results (Read 654 times) previous topic - next topic

gunfus

Jan 17, 2008, 06:16 am Last Edit: Jan 17, 2008, 06:16 am by gunfus Reason: 1
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..

Cheater

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. ;)
Essentially its completely random.

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

mellis

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

nkcelectronics

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

follower

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

Yes.

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


--Phil.

Go Up