Control the brightness of light

I want control dimming light. I use moc3052 and bt139. I chose the scheme of the datasheet moc3052.

Lamp on / off works, but I do not understand how to control the brightness of the lamp. Do I understand correctly that the triac need to open the half-wave part of the missing? What do I need to make a delay before turning on the triac? I've always worked full-light glow with varying delay before turning on the triac.

int pin = 3;

void setup()			  
{
  pinMode(pin, OUTPUT);
  attachInterrupt(0, light, RISING);
}

void light()
{
  delayMicroseconds(1000);
  digitalWrite(pin, HIGH);
  delayMicroseconds(20);
  digitalWrite(pin, LOW); 
}

void loop()
{
}

Dimming an AC light in this way is not easy. Timing is critical.

Unlike DC, it's not just a case of varying the amount of time that the light is on for, but it is a case of chopping and modifying the AC waveform.

It's also quite dangerous playing with mains AC, so I cannot condone this in any way.

You should look at (and thoroughly understand) this site: Voltage Controlled AC Light Dimmer