Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int relayPin = 2;
- const int audioPin = 3;
- const int dotDuration = 130; // Durata punctului în milisecunde
- const int dashDuration = 3 * dotDuration;
- void setup() {
- pinMode(relayPin, OUTPUT);
- pinMode(audioPin, OUTPUT);
- }
- void loop() {
- String cuvinte[] = {"MOE", "MOI", "MOS", "MOH", "MO5"};
- for (int i = 0; i < 5; i++) { // Parcurge fiecare cuvânt
- for (int j = 0; j < 15; j++) { // Repetă de 15 ori
- transmiteMorse(cuvinte[i]); // Transmite cuvântul
- }
- }
- delay(5000); // Pauză de 5 secunde după fiecare ciclu complet
- }
- void transmiteMorse(String cuvant) {
- for (int i = 0; i < cuvant.length(); i++) {
- char litera = cuvant.charAt(i);
- simbolMorse(litera);
- // Spațiu între litere (3 unități)
- if (i < cuvant.length() - 1) {
- delay(3 * dotDuration);
- }
- }
- // Spațiu între cuvinte (7 unități)
- delay(7 * dotDuration);
- }
- void simbolMorse(char caracter) {
- String cod;
- switch (caracter) {
- case 'M': cod = "--"; break;
- case 'O': cod = "---"; break;
- case 'E': cod = "."; break;
- case 'I': cod = ".."; break;
- case 'S': cod = "..."; break;
- case 'H': cod = "...."; break;
- case '5': cod = "....."; break;
- default: return;
- }
- for (int i = 0; i < cod.length(); i++) {
- digitalWrite(relayPin, HIGH);
- tone(audioPin, 1000); // Generează ton de 1000Hz
- if (cod[i] == '.') {
- delay(dotDuration);
- } else {
- delay(dashDuration);
- }
- digitalWrite(relayPin, LOW);
- noTone(audioPin);
- // Spațiu între simboluri (1 unitate)
- if (i < cod.length() - 1) delay(dotDuration);
- }
- }
Advertisement
Comments
-
- Code for basic training in Radio Orienteering sport, Fox hunting, for ARDUINO UNO transmitting basic morse MOE, MOI, MOS, MOH, MO5. with 2 exits: Pin 3 speaker with 1000 Hz tone and Pin 2 relay output for TX keying.
- Every fox is sent 15 times, after that the code moves to the next fox. At the end is a 5 seconds pause then the cycle start again.
- The dotDuration can be adjusted to change the speed.
Add Comment
Please, Sign In to add comment
Advertisement