FlashWebHost.com Ham Radio Resources
FlashWebHost.com  |   Resources  |   Ham Radio Circuits  |   Ham Radio  |   Call Sign Server  |   SSB Transceiver  |   Matrimonial  |   Tell-A-Friend

MORSE CODE TUTOR

Download Morse Tutor (30 kb)
Source code (morse.cpp) and Compiled DOS Binary (morse.exe)

Morse Tutor is a program written in C++. It can be used for learning or sending morse code. Morse code uses long (dash) and short (dot) sounds to communicate. The dot is the basic unit and the dash is equal to the length of three dot's.

Morse Code was developed by Samual Morse in 1897. Due to the advantages like overriding noise, static, use of simple transmitter and low power requirements, it is still used for communication.

The program provides character mode, line mode and file mode of operation. In character mode, separate character can be practiced. In file mode, stored messages can be sent. This mode also have provision for creating a new message file. The speed can be set between 5 WPM (words per minute) to 20 WPM, amd tone can be varied between 100Hz and 4000Hz (4KHz) using the program. The default speed is 12 WPM and tone is 700 Hz.

Recently i have modified the source code to include RANDOM MODE to Morse Tutor. After adding the random mode, i found morse tutor much more interesting. User can specify the number of random words to be generated and the Morse Tutor will generate the random words. You can download the zip file which contains the latest version of Morse Tutor.

NOTE : I suggest you to compile the source code (morse.cpp) in the distribution and use it. If you are going to use included binary (morse.exe), please check for presence of any virus before executing Morse Tutor. Your computer need a Speaker (not a soundcard) to produce the generated morse code.


//File : morse.cpp
//Author : Yujin Boby
//Email : vu3prx@yahoo.com, info@flashwebhost.com
//Home : http://www.flashwebhost.com/


#include<iostreams.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>


void morse();
int mnu_one();
void mode_line();
void mode_file();
void mode_sett();
void mode_char();

char in;
int FREQ=700; // 700 Hz
int DOT=50; // 12 wpm
void main()
{
int choice;
while(1)
{
choice=mnu_one();
if (choice==1) mode_char();
else
if(choice==2) mode_line();
else
if(choice==3) mode_file();
else
if(choice==4) mode_sett();
else
if(choice==5) break;
}
gotoxy(25,19); cout<<"73's & Good Bye.. de VU3PRX\n\n\n";
}
/**************************** MORSE()*********************************/
void morse()
{
char code[8];
switch(toupper(in))
{
case 'A': strcpy(code,".-"); break;
case 'B': strcpy(code,"-..."); break;
case 'C': strcpy(code,"-.-."); break;
case 'D': strcpy(code,"-.."); break;
case 'E': strcpy(code,"."); break;
case 'F': strcpy(code,"..-."); break;
case 'G': strcpy(code,"--."); break;
case 'H': strcpy(code,"...."); break;
case 'I': strcpy(code,".."); break;
case 'J': strcpy(code,".---"); break;
case 'K': strcpy(code,"-.-"); break;
case 'L': strcpy(code,".-.."); break;
case 'M': strcpy(code,"--"); break;
case 'N': strcpy(code,"-."); break;
case 'O': strcpy(code,"---"); break;
case 'P': strcpy(code,".--."); break;
case 'Q': strcpy(code,"--.-"); break;
case 'R': strcpy(code,".-."); break;
case 'S': strcpy(code,"..."); break;
case 'T': strcpy(code,"-"); break;
case 'U': strcpy(code,"..-"); break;
case 'V': strcpy(code,"...-"); break;
case 'W': strcpy(code,".--"); break;
case 'X': strcpy(code,"-..-"); break;
case 'Y': strcpy(code,"-.--"); break;
case 'Z': strcpy(code,"--.."); break;
case '1': strcpy(code,".----"); break;
case '2': strcpy(code,"..---"); break;
case '3': strcpy(code,"...--"); break;
case '4': strcpy(code,"....-"); break;
case '5': strcpy(code,"....."); break;
case '6': strcpy(code,"-...."); break;
case '7': strcpy(code,"--..."); break;
case '8': strcpy(code,"---.."); break;
case '9': strcpy(code,"----."); break;
case '0': strcpy(code,"-----"); break;
case '.': strcpy(code,".-.-.-"); break;
default: cout<<endl<<"MSG-Switch::Invalid
character \"";
cout<<in<<"\""<<endl; break;
}
int len=strlen(code);
for(int i=0;i<len;i++)
{ sound(FREQ);
if(code[i]=='.') delay(DOT);
else
if(code[i]=='-') delay(3*DOT);
nosound(); delay(DOT);
}
delay(3*DOT);
}

/******************MNU_ONE()********************************************/
int mnu_one()
{
int ch;
clrscr();
gotoxy(30,7); cout<<"MORSE CODE TUTOR";
gotoxy(30,8); cout<<"~~~~~~~~~~~~~~~~";
gotoxy(33,9); cout<<"1. CHARACTER MODE";
gotoxy(33,10); cout<<"2. LINE MODE";
gotoxy(33,11); cout<<"3. FILE MODE";
gotoxy(33,12); cout<<"4. SETTINGS";
gotoxy(33,13); cout<<"5. EXIT";
gotoxy(30,15); cout<<"Enter your choice : ";
gotoxy(25,19); cout<<"A FreeWare From VU3PRX";
gotoxy(50,15); cin>>ch; return ch;
}
/***************************** MODE_LINE() ***********************/
void mode_line()
{
int flag=1;
char line[80];
clrscr();
cout<<"LINE MODE"<<endl;
cout<<"Type '*' to END sending"<<endl;
while(flag)
{
gets(line);
int len=strlen(line);
for(int i=0;i<len;i++)
{
in=line[i];
if(in==' ') { delay(6*DOT); continue; }
else if(in=='*') { flag=0; break; }
morse();
}

}
}
/**************************** MODE_FILE() ********************************/
void mode_file()
{
FILE *fp;
char fname[10];
clrscr();
cout<<"Enter file name : ";
cin>>fname;
if((fp=fopen(fname,"r"))!=NULL)
{
while((in=getc(fp))!=EOF)
{
if(in==' ') { delay(6*DOT); continue; }
morse();
}
}
else
{
char ans;
cout<<endl<<"File not found, Create New (Y/N) ?
";
cin>>ans;
if((ans=='y')||(ans=='Y'))
if((fp=fopen(fname,"w"))!=NULL)
while((ans=getchar())!='\n')
putc(ans,fp);
}

fclose(fp);
}

/************************** void mode_sett();*********************/
void mode_sett()
{
int cho;
clrscr();
cout<<"1. CHANGE FREQUENCY"<<endl;
cout<<"2. CHANGE SPEED"<<endl;
cout<<endl<<"Enter your choice : ";
cin>>cho;
if(cho==1)
{ cout<<endl<<"Current Frequency of tone is
"<<FREQ<<" Hz"<<endl;
cout<<"The valid frequency range is from 100 Hz to
4000 Hz"<<endl;
cout<<endl<<"Enter the new frequency : ";
int tmp;
cin>>tmp;
cout<<endl<<endl;
if((tmp>99)&&(tmp<4001))
{
FREQ=tmp;
cout<<"Now the Frequency is changed to "<<FREQ<<"
Hz"<<endl;
}
else cout<<"Error : Invalid frequency range";
getch();
}
if(cho==2)
{
int speed;
speed=36000/(DOT*60);
cout<<"\nCurrent speed is "<<speed<<"
Words/Minute"<<endl;
cout<<"The valid Speed is from 5 WPM to 20 WPM "<<endl;
cout<<"\n\nEnter new speed : ";
cin>>speed;
if((speed>4)&&(speed<21))
{
DOT=36000/(speed*60);
cout<<"\n\nNow the speed is "<<speed<<"
Words Per Minute";
}
else cout<<"\n\nError : Speed "<<speed<<"
WPM not allowed\n";
getch();
}
}
/*********************** MODE_CHAR() ***********************************/
void mode_char()
{
clrscr();
cout<<"CHARACTER MODE"<<endl;
cout<<"Type '*' to END sending"<<endl;
while(1)
{
in=getche();
if(in==' ') { delay(6*DOT); continue; }
else if(in=='*') break;
morse();
}
}


Website designed by FlashWebHost.com. All rights reserved.