Hello World -

New to Arduino. Thought I'd start with a classic intro program "hello world" using the led and morse code.

Nice straightforward language!

// Hello World in Morse Code

//Map led to port 13
const int LED = 13; //LED connected to port 13

//Define needed durations, using Morse code standard multiples, which use the duration of DOT as a base
const int DOT = 100; //Morse Code Dot duration
const int DASH = DOT3; //Morse Code Dash duration
const int SPACE = DOT; //Morse Code intra-letter pause duration
const int LETTER = DOT
2; //Morse Code inter-letter duration
//assumes one space preceding it (normally Dot3)
const int WORD = DOT
7; //Morse Code inter-word duration
const int PHRASE = DOT*50; //Arbitrary inter-phrase duration

void setup() {
// initialize the digital pin as an output.
pinMode(LED, OUTPUT);
}

//Define Dot and Dash
void dash() {
digitalWrite(13, HIGH); // set the LED on
delay(DASH); // DASH duration
digitalWrite(13, LOW); // set the LED off
delay(SPACE); // Space duration
}
void dot() {
digitalWrite(13, HIGH); // set the LED on
delay(DOT); // DASH duration
digitalWrite(13, LOW); // set the LED off
delay(SPACE); // Space duration
}

//Define needed letters
void letterD() {
dash();
dot();
dot();
delay(LETTER); // Letter duration
}
void letterE() {
dot();
delay(LETTER); // Letter duration
}
void letterH() {
dot();
dot();
dot();
dot();
delay(LETTER); // Letter duration
}
void letterL() {
dot();
dash();
dot();
dot();
delay(LETTER); // Letter duration
}
void letterO() {
dash();
dash();
dash();
delay(LETTER); // Letter duration
}
void letterR() {
dot();
dash();
dot();
delay(LETTER); // Letter duration
}
void letterW() {
dash();
dot();
dot();
dash();
delay(LETTER); // Letter duration
}

//Loop
void loop() {
letterH();
letterE();
letterL();
letterL();
letterO();
delay(WORD);
letterW();
letterO();
letterR();
letterL();
letterD();
delay(PHRASE);
}

Hi, nice little thing you made. Why don't you try to make a Morse Library :wink: (maybe there already is one?)
If you do, you could make other projects using your own library and you can share it with others.
It would be a very good exercise. XD

Go for more :wink:

I'm almost done with a more complete library, which I'll post. Thanks for the suggestion.