Arduino + Wire = Morse Code AM Radio Beacon

I add some lines to your code and now can send any message you want, just type some text an send it through serial COM and the Arduino will broadcast to the air in morse code, download this program (http://www.instructables.com/files/orig/F8J/EV05/NULEXCFDUNP/F8JEV05NULEXCFDUNP.zip) install it, and plug an comun AM radio to your sound card MIC tuned at around 1337 and you will see the message you send.

Setup the program with the main filter to 1000Hz, and with the left click of the mouse put the red line where you see the peaks when you send the messages.

this will automaticaly translate the message.

for better info check this http://www.instructables.com/id/Build-a-computer-controlled-radio-transmitter/.

long millisAtStart=0;
long millisAtEnd=0;

/*a = '01';
 b = '1000';
 c = '1010';
 d = '100';
 e = '0';
 f = '0010';
 g = '110';
 h = '0000';
 i = '00';
 j = '0111';
 k = '101';
 l = '0100';
 m = '11';
 n = '10';
 o = '111';
 p = '0110';
 q = '1101';
 r = '010';
 s = '000';
 t = '1';
 u = '001';
 v = '0001';
 w = '011';
 x = '1001';
 y = '1011';
 z = '1100';*/

int letters[26][4] = {
  {
    0,1          }
  ,
  {
    1,0,0,0          }
  ,
  {
    1,0,1,0          }
  ,
  {
    1,0,0          }
  ,
  {
    0          }
  ,
  {
    0,0,1,0          }
  ,
  {
    1,1,0          }
  ,
  {
    0,0,0,0          }
  ,
  {
    0,0          }
  ,
  {
    0,1,1,1          }
  ,
  {
    1,0,1          }
  ,
  {
    0,1,0,0          }
  ,
  {
    1,1          }
  ,
  {
    1,0          }
  ,
  {
    1,1,1          }
  ,
  {
    0,1,1,0          }
  ,
  {
    1,1,0,1        }
  ,
  {
    0,1,0         }
  ,
  {
    0,0,0         }
  ,
  {
    1          }
  ,
  {
    0,0,1          }
  ,
  {
    0,0,0,1          }
  ,
  {
    0,1,1          }
  ,
  {
    1,0,0,1          }
  ,
  {
    1,0,1,1          }
  ,
  {
    1,1,0,0          }
  ,
};                     

const long period_broadcast=8; //period of shortest broadcast (256 port changes)

#define LENGTH_DIT 64
//number of period_broadcasts in one 'dit',
//all other lengths are scaled from this

const int length_dit=LENGTH_DIT;//number of periods for dit
const int pause_dit=LENGTH_DIT;//pause after dit
const int length_dah=3*LENGTH_DIT;//number of persots for dah
const int pause_dah=LENGTH_DIT;//pause after dah
const int length_pause=7*LENGTH_DIT;//pause between words

void dit(void);
void dah(void);
void pause(void);
void broadcast(int N_cycles);
void dontbroadcast(int N_cycles);

// ### INC ### Increment Register (reg = reg + 1)
#define ASM_INC(reg) asm volatile ("inc %0" : "=r" (reg) : "0" (reg))

void setup()
{

  Serial.begin(9600);
  DDRB=0xFF;  //Port B all outputs
  //Do one dit to determine approximate frequency
  millisAtStart=millis();
  dit();
  millisAtEnd=millis();
  Serial.print(millisAtEnd-millisAtStart);
  Serial.print(" ");
  Serial.print((length_dit+pause_dit)*period_broadcast*256/(millisAtEnd-millisAtStart)/2);
  Serial.print("kHz ");
  Serial.println();
}

void loop()
{
  char buffer;
  int L=0;
  int P=0;  

  if (Serial.available())
  {
    buffer=Serial.read();
    switch (buffer) {
    case 'a': 
      L=0;
      P=2;
      break;
    case 'b': 
      L=1;
      P=4;
      break;
    case 'c': 
      L=2;
      P=4;
      break;
    case 'd': 
      L=3;
      P=3;
      break;
    case 'e': 
      L=4;
      P=1;
      break;
    case 'f': 
      L=5;
      P=4;
      break;
    case 'g': 
      L=6;
      P=3;
      break;
    case 'h': 
      L=7;
      P=4;
      break;
    case 'i': 
      L=8;
      P=2;
      break;
    case 'j': 
      L=9;
      P=4;
      break;
    case 'k': 
      L=10;
      P=3;
      break;
    case 'l': 
      L=11;
      P=4;
      break;
    case 'm': 
      L=12;
      P=2;
      break;
    case 'n': 
      L=13;
      P=2;
      break;
    case 'o': 
      L=14;
      P=3;
      break;
    case 'p': 
      L=15;
      P=4;
      break;
    case 'q': 
      L=16;
      P=4;
      break;
    case 'r': 
      L=17;
      P=3;
      break;
    case 's': 
      L=18;
      P=3;
      break;
    case 't': 
      L=19;
      P=1;
      break;
    case 'u': 
      L=20;
      P=3;
      break;
    case 'v': 
      L=21;
      P=4;
      break;
    case 'w': 
      L=22;
      P=3;
      break;
    case 'x': 
      L=23;
      P=4;
      break;
    case 'y': 
      L=24;
      P=4;
      break;
    case 'z': 
      L=25;
      P=4;
      break;
    }
    for (byte i=0; i<P; i++) {
      if (letters[L][i] == 0){
        dit();
      }
      else {
        dah();
      }
    }
    pause();
  }
  /*dah();
   dit();
   dah();
   dah();
   pause(); //Y
   dah();
   dit();
   dah();
   dah();
   pause();//Y
   dah();
   dah();
   dit();
   dit();
   pause();//Z
   pause();*/
}

void dit(void)
{
  for(int i=0;i<length_dit;i++)
  {
    broadcast(period_broadcast);
  }
  for(int i=0;i<pause_dit;i++)
  {
    dontbroadcast(period_broadcast);
  }
}


void dah(void)
{
  for(int i=0;i<length_dah;i++)
  {
    broadcast(period_broadcast);
  }
  for(int i=0;i<pause_dah;i++)
  {
    dontbroadcast(period_broadcast);
  }
}

void pause(void)
{
  for(int i=0;i<length_pause;i++)
  {
    dontbroadcast(period_broadcast);
  }
}

void broadcast(int N_cycles)
{
  unsigned int portvalue;
  for (int i=0;i<N_cycles;i++)
  {
    portvalue=0;
    do
    {
      PORTB=portvalue;
      ASM_INC(portvalue);
    }
    while(portvalue<255);
  }
}

void dontbroadcast(int N_cycles)
{
  unsigned int portvalue;
  PORTB=0x00;
  for (int i=0;i<N_cycles;i++)
  {
    portvalue=0;
    do
    {
      ASM_INC(portvalue);
      //add some assembly No OPerations to keep timing the same
      asm volatile ("NOP");
    }
    while(portvalue<255);
  }
}