Telegraph Project from Quick-start Guide runs incorrectly

But when I tried removing "strlen(message)" and replacing it with the number 4 (to get it to loop 4 times) the result was still the same as above.

But, message is "SM", so strlen(message) returns 2. The loop you are modifying is looping through each letter in the message, defining a new "letter" to send to output_code.

The Telegraph class has a fundamental flaw. Class constructors are called before the init() method in the startup sequence. The init() method initializes all the pins to input. The constructor for the Telegraph class sets the specified pin to output before init() sets it input.

The Telegraph class needs a begin() method (like Serial.begin()) in which the hardware items are placed.

Telegraph::Telegraph(const int output_pin, const int dit_length)
 {
  _output_pin = output_pin;
  _dit_length = dit_length;
  _dah_length = dit_length * 3;
}

void Telegraph::begin()
{
  pinMode(_output_pin, OUTPUT);
}

Since you have the serial port initialized, and are writing some data to the serial port, add

Serial.print("Pattern to output: ");
Serial.println(code);

to the top of output_code.

This will help determine if the problem is with the code to output a single "letter", as output_code is doing, or with send_message.