SMD 328P-AU and Anlogread

I designed a PCB and connected a potentiometer to GND - VCC and Analog pin 2
I uploaded a bootloader for a uno. configured as uno.

When i read my analog port i don’t get anything else then VCC

we i meassure it with my scope or multimeter i (measure on the pin of the chip itself ) the voltage change from 5v vcc to 0. so thats okay.
But why is my code not working

analogWrite(ledPin, analogRead(A2));

The led is always fully on. regardless the voltage i measure on the A2 pin.

is there something wrong with the chip or did i do something stupids.

Kind regards


analogRead returns an int analogWrite sends out a byte.

try this: analogWrite(ledPin, (analogRead(A2)>>2));

Make sure ledPin is one of 3,5,6,9,10,11, they are the PWM output pins.

i will try. Sorry its pin 5, If i run the fade sketch the fading works fine. so its just the analog read. I normaly use the analogread for a delay but because that wasn't working properly i tried it with the pwm led

I let you know

OK, is it possible that your surface mount chip pin "arduino A2" is not soldered on for some reason? Can you also post your board design for extra pairs of eyes to check?