// MARITIME SIGNALLING LIGHT SOFTWARE
//
// Tested with Arduino Uno and Nano Every
//
// The International Code of Signals (ICS) is an international system of signals and codes
// for use by vessels to communicate important messages regarding safety of navigation and
// related matters. Signals can be sent by flaghoist, signal lamp ("blinker"), flag
// semaphore, radiotelegraphy, and radiotelephony. The International Code is the most
// recent evolution of a wide variety of maritime flag signalling systems.
//
// See International Code of Signals, 2005 ed. (IMO IA994E), IMO International Maritime
// Organization, 2005, ISBN 978-92-801-4198-6
//
// This program can be used for flashing light signalling by morse codes.
// You don't have to be familiar with morse code in order to send a message.
//
// You need an Arduino, a mosfet, signalling lamp and computer / or mobile phone with
// USB OTG cable and for example Kai Morich's (Gerhart-Hauptmann-Str. 13, 68766 Hockenheim,
// Germany) "Serial USB Terminal" -program for Android phones from Google Play.
//
// I found no signalling lamp for my boat so I made it by myself.
//
// Jarmo Kiuru OH8JK - Oulu, Finland.
const int mosfet = 2; // The pin the mosfet is connected to.
void setup() {
// Initialize digital pin as an output.
pinMode(mosfet, OUTPUT);
}
void loop() {
// Delays of morse code - you can adjust for your needs.
const int dotMorse = 300; //A dot is one unit
const int dashMorse = 900; //A dash is three units
const int breakMorse = 300; //The space between same letter is one unit
const int spaceletterMorse = 900; //The space between letters is three units
const int breakwordsMorse = 2100; //The space between words is seven units
String merkki = "";
char lahete[] = "";
char MorseCode[8] = "";
// HOX! SMALL LETTERS
char LATIN_CHARACTERS[] = {
// Numbers
'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
// Letters
'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',
// Special
'.', '?', '@', ' '
};
//MORSE_CHARACTERS are all eight letters long filled with spaces at the end
String MORSE_CHARACTERS[] = {
// Numbers
"----- ", ".---- ", "..--- ", "...-- ", "....- ",
"..... ", "-.... ", "--... ", "---.. ", "----. ",
// Letters
".- ", "-... ", "-.-. ", "-.. ", ". ",
"..-. ", "--. ", ".... ", ".. ", ".--- ",
"-.- ", ".-.. ", "-- ", "-. ", "--- ",
".--. ", "--.- ", ".-. ", "... ", "- ",
"..- ", "...- ", ".-- ", "-..- ", "-.-- ", "--.. ",
// Special
".-.-.- ", "..--.. ", ".--.-. ", " "
};
// This opens the serial port.
Serial.begin(9600);
delay(10); // Wait for a 1/100 second
// Here the program get a character from the terminal via serial port.
merkki = Serial.readString();
delay(10); // Wait for a 1/100 second
// This goes thru all latin characters and finds out what you have typed in.
for (int h=0; h < merkki.length(); h++) {
merkki.toCharArray(lahete, merkki.length());
for (int i=0; i < 40; i++) {
// This converts MORSE_CHARACTERS as an char array and place the array into variabel MorseCode.
MORSE_CHARACTERS[i].toCharArray(MorseCode, 8);
// When this if sentence finds a match to what you have typed in it sends it using the Morse code.
if (LATIN_CHARACTERS[i] == lahete[h]) {
Serial.print(" ");
Serial.print(LATIN_CHARACTERS[i]);
Serial.print(" ");
for (int j=0; j < 8; j = j+1) {
if (MorseCode[j] == '-') {
digitalWrite(mosfet, HIGH);
Serial.print('-');
delay(dashMorse);
digitalWrite(mosfet, LOW);
delay(breakMorse);
}
else if (MorseCode[j] == '.') {
digitalWrite(mosfet, HIGH);
Serial.print('.');
delay(dotMorse);
digitalWrite(mosfet, LOW);
delay(breakMorse);
}
else if (MorseCode[j] == ' ') {
// If MorseCode's first character is space then it separates two words.
if (MorseCode[j] == ' ' && j == 0) {
digitalWrite(mosfet, LOW);
delay(breakwordsMorse);
}
// All Morse symbols are eight character long and when the program finds first space
// it interrupts the for sentence.
break;
}
}
Serial.println();
delay(spaceletterMorse);
}
}
}
}
Comments