For my second tech demo, I wanted to make a project using flashing LEDs to display morse code. After several failed attempts at using different codes and/or libraries to accomplish this, I found a morse code library that turned the complex task into some very simple code and with a few easy changes I could modify to work for four LEDs rather than one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <ArduinoMorse.h>
 
ArduinoMorse morse1(5);
ArduinoMorse morse2(6);
ArduinoMorse morse3(7);
ArduinoMorse morse4(8);
 
const int LED1 (5);
const int LED2 (6);
const int LED3 (7);
const int LED4 (8);
 
void setup() {
delay(1000);
}
 
void loop() {
// Flash in morse code:
morse3.process("Do");
delay(50);
 
morse4.process("you");
delay(50);
 
morse3.process("bite");
delay(50);
 
morse4.process("your");
delay(50);
 
morse3.process("thumb");
delay(50);
 
morse4.process("at");
delay(50);
 
morse3.process("us");
delay(50);
 
morse4.process("sir");
delay(500);
 
morse1.process("I");
delay(50);
 
morse2.process("do");
delay(50);
 
morse1.process("bite");
delay(50);
 
morse2.process("my");
delay(50);
 
morse1.process("thumb");
delay(50);
 
morse2.process("sir");
delay(500);
 
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
 
digitalWrite(LED2, HIGH);
delay(1000);
 
digitalWrite(LED1, HIGH);
delay(1000);
 
digitalWrite(LED4, HIGH);
delay(1000);
 
digitalWrite(LED3, HIGH);
delay(1000);
 
exit (0);
}

Sources:

https://github.com/willvincent/ArduinoMorse

https://www.marginallyclever.com/2014/11/how-to-blink-morse-code-with-arduino/

https://makezine.com/projects/arduino-morse-code-flasher/

http://www.instructables.com/id/Morse-code-with-arduinoLED/

http://www.instructables.com/id/Arduino-Morse-Code/