Arduino dimmer just flashing and inputs are bad

Should this code work? Arduino Mega 2560. Solid state relay on PIN 30 and zero crossing input on PIN2 (interrupt 0).
requestValue should be between 0 and 255.
My lightbulb is just flashing about twice a second. If I change OCR3A to 1280 or 2560, then lightbulb is a lot dimmer but still flashing.

volatile int counterValue;
volatile int requestValue1;

boolean output_allowed = 1;
int ledstatus;
boolean ledstatusoff = 1;
boolean ledstatusred;
boolean ledstatusgreen;
boolean ledstatusblue;
boolean ledstatuswhite;
boolean ledstatuso;
boolean ledstatusr;
boolean ledstatusg;
boolean ledstatusb;
boolean ledstatusw;
boolean out14;
boolean out15;
boolean out16;
boolean out17;
boolean out18;
boolean out19;
boolean out20;
boolean out21;
boolean out22;
boolean out23;
boolean out24;
boolean out25;
boolean out26;
boolean out27;
boolean out28;
boolean out29;
boolean out30;
boolean out31;
boolean out32;
boolean out33;
boolean out34;
boolean out35;
boolean out36;
boolean out37;
void setup() {
  attachInterrupt(0, resetCounter, CHANGE); 
  cli();                      //Disable global interrupts
  TCCR3A = 0;                 //Set register to 0
  TCCR3B = 0;                 //Set register to 0
  OCR3A = 640;                //Compare match register to get desired timer count
  TCCR3B |= (1 << WGM12);     //Turn on CTC mode
  TIMSK3 |= (1 << OCIE3A);    //Enable timer compare interrupt
  TCCR3B |= (1 << CS10);      //Start timer
  sei();                      //Enable global interrupts
  requestValue1 = 200;
  
  Serial.begin(9600);
  
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(16, OUTPUT);
  pinMode(17, OUTPUT);
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);
  pinMode(20, OUTPUT);
  pinMode(21, OUTPUT);
  pinMode(22, OUTPUT);
  pinMode(23, OUTPUT);
  pinMode(24, OUTPUT);
  pinMode(25, OUTPUT);
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);
  pinMode(37, OUTPUT);
  
  pinMode(39, INPUT);
  pinMode(40, INPUT);
  pinMode(41, INPUT);
  pinMode(42, INPUT);
  pinMode(43, INPUT);
  pinMode(44, INPUT);
  pinMode(45, INPUT);
  pinMode(46, INPUT);
  pinMode(47, INPUT);
  pinMode(48, INPUT);
  pinMode(49, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  
  digitalWrite(39, LOW);
  digitalWrite(40, LOW);
  digitalWrite(41, LOW);
  digitalWrite(42, LOW);
  digitalWrite(43, LOW);
  digitalWrite(44, LOW);
  digitalWrite(45, LOW);
  digitalWrite(46, LOW);
  digitalWrite(47, LOW);
  digitalWrite(48, LOW);
  digitalWrite(49, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
}

ISR(TIMER3_COMPA_vect)
{
  counterValue++;
  counterValue &= 0xff;
  if (counterValue==requestValue1) 
  {
    digitalWrite(30, HIGH);
  } 
  else 
  {
    digitalWrite(30, LOW);
  }
}

void resetCounter()
{
  counterValue=0;
}

void loop() {   
  boolean buttonState8 = 0;
  boolean lastButtonState8 = 0;
  
  buttonState8 = digitalRead(8);

  if (buttonState8 != lastButtonState8) {
    if (buttonState8 == HIGH) {
      if(out30==0){
        out30=1;
      } else if(out30==1){
        out30=0;
      }
    }
  }
  lastButtonState8 = buttonState8;
  
  if (output_allowed) {
    if(out14) {digitalWrite(14, HIGH); } else { digitalWrite(14, LOW); }
    if(out15) {digitalWrite(15, HIGH); } else { digitalWrite(15, LOW); }
    if(out16) {digitalWrite(16, HIGH); } else { digitalWrite(16, LOW); }
    if(out17) {digitalWrite(17, HIGH); } else { digitalWrite(17, LOW); }
    if(out18) {digitalWrite(18, HIGH); } else { digitalWrite(18, LOW); }
    if(out19) {digitalWrite(19, HIGH); } else { digitalWrite(19, LOW); }
    if(out20) {digitalWrite(20, HIGH); } else { digitalWrite(20, LOW); }
    if(out21) {digitalWrite(21, HIGH); } else { digitalWrite(21, LOW); }
    if(out22) {digitalWrite(22, HIGH); } else { digitalWrite(22, LOW); }
    if(out23) {digitalWrite(23, HIGH); } else { digitalWrite(23, LOW); }
    if(out24) {digitalWrite(24, HIGH); } else { digitalWrite(24, LOW); }
    if(out25) {digitalWrite(25, HIGH); } else { digitalWrite(25, LOW); }
    if(out26) {digitalWrite(26, HIGH); } else { digitalWrite(26, LOW); }
    if(out27) {digitalWrite(27, HIGH); } else { digitalWrite(27, LOW); }
    if(out28) {digitalWrite(28, HIGH); } else { digitalWrite(28, LOW); }
    if(out29) {digitalWrite(29, HIGH); } else { digitalWrite(29, LOW); }
    if(out30) {digitalWrite(30, HIGH); } else { digitalWrite(30, LOW); }
    if(out31) {digitalWrite(31, HIGH); } else { digitalWrite(31, LOW); }
    if(out32) {digitalWrite(32, HIGH); } else { digitalWrite(32, LOW); }
    if(out33) {digitalWrite(33, HIGH); } else { digitalWrite(33, LOW); }
    if(out34) {digitalWrite(34, HIGH); } else { digitalWrite(34, LOW); }
    if(out35) {digitalWrite(35, HIGH); } else { digitalWrite(35, LOW); }
    if(out36) {digitalWrite(36, HIGH); } else { digitalWrite(36, LOW); }
    if(out37) {digitalWrite(37, HIGH); } else { digitalWrite(37, LOW); }
  }
}

EDIT:
Got this. Interrupt pin didn’t get its signal.
But now, requestValue=255 should be very dim and it is. 0 should be brightest, but it’s not. Brightest seems to be around 120. requestValue around 60-100 is flickering. 40 and 20 are pretty dim, but I can see no difference in light output.
Can anybody give some advice, what could be improved?

Also inputs don’t react on every push. It skips some button pushes. If I disable dimmer, everything is fine.
What could be causing this? I have many buttons and none of them is working fine on first press.

boolean out14;
boolean out15;

boolean out36;
boolean out37;

why not making an array ? – see also - http://www.arduino.cc/en/Reference/Array -

boolean out[25]; and use (nr-14) as index

furthermore use loops

for (int pin=13; pin < 37; pin++) pinMode(pin, OUTPUT);
for (int pin=39; pin < 49; pin++) pinMode(pin, INPUT);
for (int pin=39; pin < 49; pin++) digitalWrite(pin, LOW);
for (int pin=5; pin < 8; pin++) pinMode(pin, INPUT);

and

if(out14) {digitalWrite(14, HIGH); } else { digitalWrite(14, LOW); }

can be rewritten as digitalWrite(14, out14 ? HIGH : LOW); ( ? is a special if operator that is especially for cases like this)
or even shorter digitalWrite(14, out14); as true and false map upon HIGH and LOW …

and by using the array for out as described above

for (int pin=14; pin < 37; pin++) 
{
  digitalWrite(pin, out[pin-14]);
}

just a few tips

Thanks, but I optimize code later if I get everything working.