Code looks OK (ish). You realise digital pin 3 (where you analogWrite is going to) is a different pin to analogue input 3?