ATtiny input pullup not pulling up?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've seen this in other posts but still can't solve it... I'm trying to set a digital input for internal pullup.  But the operation is flaky - I have to connect the input to 5V for it to respond as expected.  If I touch the pin with my finger, it flashes on & off.  I measure the input (with a good quality multimeter) as about 0.25V, but it "wanders' around just like the pullup isn't really connected.  Here's my code - any thoughts? thanks, I'm an electronics veteran but an AVR software newb.

#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
//#include <avr/interrupt.h>
//#include <avr/sleep.h>

int main(void)
{	
	PORTB = ((1<<PB0) | (1<<PB1));
	DDRB = (1<<DDB1);
	_delay_ms(10);

    for (;;) {
		if (!(PINB & 0b00000001)) {
			PORTB = 0;
		}
		else {
			PORTB |= (1<<PB1);
		}
		_delay_ms(50);
	}
}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

paulofelora wrote:
PORTB = 0;

That line turns off the pullup.

 

You want PORTB &= ~(1<<PB1);

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahhhh thanks theusch, will try it - paul

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

works like a champ, mucho grass, sir

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

paulofelora wrote:
mucho grass, sir

No No Song

Ringo Starr

Huh-huh! Huh-huh!
(Ah-ah-ah-ah-ah)
(Aye-aye-aye-aye)

A lady that I know just came from Colombia
She smiled because I did not understand
Then she held out some marijuana, ha ha
She said it was the best in all the land

And I said
"No, no, no, no, I don't smoke it no more
I'm tired of waking up on the floor

No, thank you, please, it only makes me sneeze
And then it makes it hard to find the door"

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.