Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Maltaeron on March 26, 2008, 10:20:31 PM

Title: AtMega168 input pin floating high
Post by: Maltaeron on March 26, 2008, 10:20:31 PM
I have eight inputs from a controller for my robot, where each input has current when a button is pressed and is floating without. My problem is that the pins -- or at least the first one -- tends to float high by itself. Do I need to attach pull-down resistors to bring it back down? seems weird to me that after grounding it I wait a few seconds and it is back high again. I don't want to have to put 8 more resistors onto my super-simple circuit (only 3 Led resistors  :)).

So should add the pull-downs? -- I haven't even attached my controller yet --
If so, what value would be best?
If not, what else could I do?

Thanks
Title: Re: AtMega168 input pin floating high
Post by: bulkhead on March 27, 2008, 01:20:00 AM
That's strange, I've never heard of pull-down resistors being used, but then I haven't heard much.  Usually pullup resistors are used, and the switch/button goes to ground.  How exactly do you have it wired right now?  Do you have a schematic?
Title: Re: AtMega168 input pin floating high
Post by: Maltaeron on March 27, 2008, 09:20:15 AM
Hmm, I guess I could reverse the system, it would be a little weird for the red wire to be ground though... =]

Very simple, power goes to one side of a button, then from the other side of the button another wire goes to a port on my AtMega168

If I switched It what would I have to do? Just reconnect power to ground, add 8 pull-ups, and internally note that a 0 is button down?

Thanks
Title: Re: AtMega168 input pin floating high
Post by: frank26080115 on March 27, 2008, 10:10:01 AM
ATMEGA168 has built in pull up resistors that are enabled by default. Look in the datasheet to find out how to disable them.
Title: Re: AtMega168 input pin floating high
Post by: bulkhead on March 27, 2008, 12:29:23 PM
Yes, try switching it around for at least one button to test.  If it does have built in pullup resistors, you just need to connect your I/O pin to the button, and the button to ground.
Title: Re: AtMega168 input pin floating high
Post by: Admin on March 30, 2008, 03:19:31 PM
Pull down resistors will work fine.

But as frank said, you can also activate internal resistors using software in your ATmega.

For example, this line of code will turn on pull up resistors on PORTC for the ATmega168:

PORTC = 0xFF;