ATTINY84 PWM

Code attached below. Don't think this a coding issue - as it works on the UNO - with different pin assignments... the code is very BASIC! I'm new to all of this. Apols for the structure etc....

In case its not obvious the code drives a motor which raises and lowers a chicken house door dependent on light.

int photocellReading; // var for ldr reading
int sw_level = 340; // light level for switching

int doorstate = 0; // is the door open or closed 1=closed 0=open
int x = 1; // used to ensure motor keeps running once activated
int time = 0; // used to wait until after dark and not close immediately
int i=255; // motor speed 35 is slowest, 255 fastest
const int photocellPin = 0; // ldr on A5 - don't use A0 or A1 with motorshield.
const int doordownPin = 1; // door closed switch input pin
const int doorupPin = 2; // door open switch input pin
const int enable = 6; // motor pulse pin
const int forward = 4; // motor direction
const int reverse = 5; // motor direction
const int enable = 6; // motor pulse pin

void setup() {
pinMode(reverse, OUTPUT); // Initiates Motor Channel A pin
pinMode(forward, OUTPUT); // Initiates Brake Channel A pin
pinMode(doorupPin, INPUT); // Door Up Switch is an input
pinMode(doordownPin, INPUT); // Door Down Switch is an input

}

void loop() {
photocellReading = analogRead(photocellPin);
if ((photocellReading < (sw_level)) && (doorstate != 1)) {(time = time + 1);}
if (photocellReading >sw_level) (time = 0);
if (photocellReading > (sw_level)) {(doorup());} // goto doorup
if ((photocellReading < (sw_level)) && (doorstate != 1) && (time >= 3)) {doordown();} //goto door down
delay(20000);
}

void doorup(){
digitalWrite(reverse, LOW); //Set motor direction
digitalWrite(forward, HIGH); //Set motor direction
while (x=1) {
analogWrite(enable, i);
int pinState = digitalRead(doorupPin);
if (pinState == HIGH) {(digitalWrite(forward, LOW)); (doorstate = 0); break;} //stop
delay(25);
}
}

void doordown(){
digitalWrite(reverse, HIGH); //Set motor direction
digitalWrite(forward, LOW); //Set motor direction
while (x=1) {
analogWrite(enable, i);
int pinState = digitalRead(doordownPin);
if (pinState == HIGH) {(digitalWrite(reverse, LOW)); (time = 0); (doorstate = 1); break;} //stop
delay(25);
}
}