Arduino Code for Amir Fattal

// Dr. Liu 10/03/2010
// mod J.D.D. 04/01/2011

#define period 90 //13.33 WPM // amir wants 30 and 10
//#define buzzerPin 11
//#define ledPin 13
const int ledPin0 =  13;     // the number of the internal LED pin
const int ledPin1 =  2;      // the number of the LED pin
const int ledPin2 =  3;      // the number of the LED pin
const int Buzzer =  7;       // the number of the buzzer pin

unsigned char message[]="DREAMS ARE ALSO A WAY TO FILL UP THE DAYS THAT MAN MUST SPEND ON THIS EARTH.
THE DREAM IS NOT MUCH DIFFERENT THAN THE DEED, AS MANY THINK. ALL OF MAN'S DEEDS WERE ONCE DREAMS AND
ALL OF THEIR DEEDS WILL ONCE AGAIN BE DREAMS.   ";

unsigned char space_to_Z[][8]={" ", "!-.-.--", "\".-..-.", "# ", "$ ", "% ", "&.-...", "\'.----.",
 "(-.--.", ")-.--.-", "* ", "+.-.-.", ",--..--", "m-....-", "p.-.-.-", "/-..-.", "0-----", "1.----",
 "2..---", "3...--", "4....-", "5.....", "6-....", "7--...", "8---..", "9----.", ":---...", ";-.-.-.",
 "< ", "=-...-", "> ", "?..--..", "@.--.-.","A.-", "B-...", "C-.-.", "D-..", "E.", "F..-.", "G--.",
 "H....", "I..", "J.---", "K-.-", "L.-..", "M--", "N-.", "O---", "P.--.", "Q--.-", "R.-.", "S...",
 "T-", "U..-", "V...-", "W.--", "X-..-", "Y-.--", "Z--.."};
void setup()
{
  pinMode(ledPin0, OUTPUT);
  pinMode(ledPin1, OUTPUT); 
  pinMode(ledPin2, OUTPUT); 
  pinMode(Buzzer, OUTPUT); 
}
void loop()
{
  char pointer=0;
  char pointer2=0;
  while (pointer2>=0)
  {
    if ((message[pointer2]>=' ')&&(message[pointer2]<='Z'))
    {
      unsigned char character=message[pointer2]-' ';
      pointer=0;
      while (pointer>=0)
      {
        switch(space_to_Z[character][pointer])
        {
          case '.':
            di();
            break;
          case '-':
            dah();
            break;
          case ' ':
            delay(6*period);
            break;
          case '\0':
            delay(2*period);
            pointer=-2;
            break;
          default :
            break;
        }
        pointer++;
      }     
    }
    else if (message[pointer2]=='\0') pointer2=-2;
    pointer2++;
  } 
} 

void di()
{
  digitalWrite(ledPin0, HIGH);   // sets the LED on
  digitalWrite(ledPin1, HIGH);   // sets the LED on
  digitalWrite(ledPin2, HIGH);   // sets the LED on
  digitalWrite(Buzzer, HIGH);    // sets the buzzer on
//  analogWrite(buzzerPin, 2.5);
  delay(period);
  digitalWrite(ledPin0, LOW);    // sets the LED off
  digitalWrite(ledPin1, LOW);    // sets the LED off
  digitalWrite(ledPin2, LOW);    // sets the LED off
  digitalWrite(Buzzer, LOW);     // sets the buzzer off
//  analogWrite(buzzerPin,0);
  delay(period);
}
void dah()
{
  digitalWrite(ledPin0, HIGH);   // sets the LED on
  digitalWrite(ledPin1, HIGH);   // sets the LED on
  digitalWrite(ledPin2, HIGH);   // sets the LED on
  digitalWrite(Buzzer, HIGH);    // sets the buzzer on
//  analogWrite(buzzerPin, 2.5);
  delay(3*period);
  digitalWrite(ledPin0, LOW);    // sets the LED off
  digitalWrite(ledPin1, LOW);    // sets the LED off
  digitalWrite(ledPin2, LOW);    // sets the LED off
  digitalWrite(Buzzer, LOW);     // sets the buzzer off
//  analogWrite(buzzerPin,0);
  delay(period);
}