// код для Arduino, который будет генерировать звук частотой 800 Гц, // используя команду tone(), и кодировать фразу "всем привет. это маяк. 73!" Морзе на русском языке: // Пины для подключения пьезоэлемента int speakerPin = 9; // Задержка между сигналами Морзе int dotDelay = 200; int dashDelay = dotDelay * 3; int charDelay = dotDelay * 7; // Функция для генерации тонового сигнала void playTone(int frequency, int duration) { tone(speakerPin, frequency, duration); delay(duration); } // Функция для кодирования символов Морзе void playMorse(char morseChar) { switch (morseChar) { case 'а': case 'А': playTone(800, dotDelay); playTone(800, dashDelay); break; case 'б': case 'Б': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case 'в': case 'В': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'г': case 'Г': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'д': case 'Д': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case 'е': case 'Е': playTone(800, dotDelay); break; case 'ж': case 'Ж': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case 'з': case 'З': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case 'и': case 'И': playTone(800, dotDelay); playTone(800, dotDelay); break; case 'й': case 'Й': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case 'к': case 'К': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case 'л': case 'Л': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case 'м': case 'М': playTone(800, dashDelay); playTone(800, dashDelay); break; case 'н': case 'Н': playTone(800, dashDelay); playTone(800, dotDelay); break; case 'о': case 'О': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case 'п': case 'П': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'р': case 'Р': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'с': case 'С': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case 'т': case 'Т': playTone(800, dashDelay); break; case 'у': case 'У': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case 'ф': case 'Ф': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'х': case 'Х': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case 'ц': case 'Ц': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'ч': case 'Ч': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'ш': case 'Ш': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case 'щ': case 'Щ': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'ъ': case 'Ъ': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case 'ы': case 'Ы': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case 'ь': case 'Ь': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case 'э': case 'Э': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case 'ю': case 'Ю': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case 'я': case 'Я': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case '0': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case '1': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case '2': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case '3': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case '4': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case '5': playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case '6': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case '7': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case '8': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case '9': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case '.': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case ',': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case ':': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); break; case ';': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case '-': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case '(': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); break; case ')': playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case '\'': playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); break; case '!': playTone(800, dashDelay); playTone(800, dashDelay); playTone(800, dotDelay); playTone(800, dotDelay); playTone(800, dashDelay); playTone(800, dashDelay); break; case ' ': delay(charDelay); break; default: break; } } void setup() { pinMode(speakerPin, OUTPUT); } void loop() { // Фраза: "всем привет. это маяк. 73!" const char* morsePhrase = "всем привет. это маяк. 73!"; int phraseLength = strlen(morsePhrase); for (int i = 0; i < phraseLength; i++) { char currentChar = tolower(morsePhrase[i]); playMorse(currentChar); delay(dotDelay); } delay(charDelay * 3); // Пауза между повторениями фразы }