ATtiny85 voltage level problem

I'm trying out a simple sketch on a ATtiny85. I use the Sparkfun Tiny AVR programmer and a few simple sketches worked but the one below didn't. It's supposed to dim the LED on pin 0 depending on the voltage on the A1 pin but there's no dimming at all. I connected a potentiometer across pin 8 and 7 (A1). Turning the pot back and forth makes no difference. When I disconnected the pot and measured the voltage between A1 and GND I read 1.4V. There can't be any dimming if there's voltage on that pin all the time. What is going on with this little thing?

int pwmPin = 0;
int analogInPin = A1;

pinMode(pwmPin, OUTPUT);
pinMode(analogInPin, INPUT);

int analogIn = analogRead(analogInPin); // Read analog voltage on pin 2 (A1)

analogWrite(pwmPin, analogIn / 4); // Output analog reading to dimmable LED

Not enough information.

What value is the potentiometer? Also need to know how you connected it (wiring diagram?). Potentiometer should go between 5volt and ground with the wiper to pin 2.


The pot is 100k. Too big but should work anyway.

Connect the third pin of the pot to GND. Otherwise it does nothing.

Arduino potentiometer.

tiny pot.jpg

tiny pot.jpg

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.