Author Topic: AtMega168 input pin floating high  (Read 2804 times)

0 Members and 1 Guest are viewing this topic.

Offline MaltaeronTopic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 0
AtMega168 input pin floating high
« 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

Offline bulkhead

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
Re: AtMega168 input pin floating high
« Reply #1 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?

Offline MaltaeronTopic starter

  • Full Member
  • ***
  • Posts: 65
  • Helpful? 0
Re: AtMega168 input pin floating high
« Reply #2 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

Offline frank26080115

  • Supreme Robot
  • *****
  • Posts: 322
  • Helpful? 2
Re: AtMega168 input pin floating high
« Reply #3 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.

Offline bulkhead

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
Re: AtMega168 input pin floating high
« Reply #4 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.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: AtMega168 input pin floating high
« Reply #5 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;

 


Get Your Ad Here