-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch_sep07a.ino
32 lines (30 loc) · 970 Bytes
/
sketch_sep07a.ino
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
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
int size;
char arr[] = "-.. .. .--. .- -. ... ...."; //Enter name in the morse code
size = sizeof(arr)/sizeof(arr[0]); //Counts the size of the array that consists of name in morse code
for (int i = 0; i < size; i++) //Iterates through morse code
{
if (arr[i] == '.') //if...else conditions were used to check if the element is '.' or '-'
{
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
}
else if (arr[i] == '-')
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1500);
digitalWrite(LED_BUILTIN, LOW);
}
else if (arr[i] == ' ')
{
digitalWrite(LED_BUILTIN, HIGH);
delay(3000);
digitalWrite(LED_BUILTIN, LOW);
}
delay(200); //An unnoticable delay after each blink
}
}