I am using the Arduino IDE to program the attiny85. I want to take an incoming analog reading, then based on that reading, output a specific PWM value. Here's my circuit:

and here's my code:
// to run on attiny85
const byte pwmPin = 0;
const byte analogInPin = A2;
void setup() {
pinMode(pwmPin, OUTPUT);
}
void loop() {
int analogIn = analogRead(analogInPin);
analogWrite(pwmPin, analogIn);
}
should be very simple- I have no problems uploading code to the attiny85, and no problems with simple tests like outputting a specific PWM value (not based on the analog read). but when I try to combine the two- read, then write that value, I can't seem to get things to work. In this circuit for example- I get a reading of 1023 (5v) on the arduino micro- instead of a reading of ~ 790 (3.85v) which is what I should expect. I've used a multimeter to verify the voltages in this circuit- so I think I must either be doing something wrong with my expectations of how to wire up or program the attiny85.
analogWrite()call would "reset" the PWM of the pin, making it always up (no time to use PWM). I would trydelay(1000)for a start. – jfpoilpret Mar 09 '14 at 19:11analogIn = map(analogIn, 0, 1023, 0, 255);– GradeSchool Mar 09 '14 at 20:33