Arduino Modulation

I am currently working with the Arduino and trying to understand how modulation works and is controlled. I have been able to modulate certain frequencies but I am not sure how to vary duty cycle, below is some code for modulation that I have been working with can someone help me understand what I am missing in this code to vary duty cycle. Is there another way of coding this to add more control to the modulation?

int coil_pin = 9;

void setup()
{
  //Set pin as output
  pinMode(coil_pin, OUTPUT);
    
  //Start it as low
  digitalWrite(coil_pin, LOW);
}

void set_pin_manchester(int clock_half, int signal)
{
  //xor the data to encode
  int man_encoded = clock_half ^ signal;
  
  //I believe this part of the modulation
  if(man_encoded == 1)
  {
     digitalWrite(coil_pin, LOW);
  }
  else
  {
    digitalWrite(coil_pin, HIGH);
  }
}

void loop()
{
  //this is the data to send over the carrier freq
  int data[64] = {<binary packet to send>};
  for(int i = 0; i < 64; i++)
  {
    set_pin_manchester(0, data[i]);
    delayMicroseconds(256); //I believe by changing this and the below delay I can change the freq.
    
    set_pin_manchester(1, data[i]);
    delayMicroseconds(256); 
  }
}

You use a constant delay so your duty cycle is constant. Manchester encoding relies on phase change not duty cycle change.

So if I am understanding you right the delay is the way of controlling duty cycles?

So if I am understanding you right the delay is the way of controlling duty cycles?

Yes. set_pin_manchester() sets a pin to 0 or 1. The time the pin keeps that state is fixed by delayMicroseconds(256).

Great thank you for the clarification.

I have been thinking about this some more and I believe I might see what I need to change to control the frequency and duty cycle when modulating the signal. It looks like the first delay would probably control the duty cycle and the second one would maybe control the frequency of the signal does this sound right?

{
    set_pin_manchester(0, data[i]);
    delayMicroseconds(256);//Duty cycle control?
    
    set_pin_manchester(1, data[i]);
    delayMicroseconds(256); //Freq. control?
  }