Instructables
EDIT12/7/13: I have changed the code quite a bit. The new code includes a lookup table of morse code so that you can insert the text straight into the program and have it converted to morse for you. My motivation for this was the Hackaday Fubarino contest at http://hackaday.com/2013/12/03/new-contest-win-one-of-20-microchip-fubarino-boards/. This easter egg should not be transmitted over ham radio due to it sounding like an advertisement.


A hidden transmitter, or fox as it is sometimes called, is used by amateur radio operators for sport. Somebody hides a fox, and participants use different methods to find it. This is for practice for when there is an illegal transmitter nearby. Then the "hams" know what they are doing when tracking it down.

The transmitter usually transmits a long tone followed by a fcc granted call sign in morse code. The club I am a member of needed one of these, so I sat down and started designing it. I based it around an arduino, though this could be ported to many different microcontrollers.


 
Remove these adsRemove these ads by Signing Up

Step 1: How The Code Works

Writing this code was the first time I used custom functions, as well as an array. First I define values at the top for easy customization. Then i set up the morse code array. After declaring a few more things, I go on to the loop. First it calls my first fuction called playtone(). In the parenthathese you input how long you want it to transmit in milliseconds (1 second == 1000 milliseconds; this adds precision). This is for the hams to track the signal. After this it waits 1 second then calls my second function. called playcode(), which plays a call sign in morse code. This function uses a for loop to read through the array one character at a time. It uses a series of if statements to set the duration. After that playtone(Duration) is called. This plays the sound at the length of the character then the for loop reads the next character of the array. After it has gone through all characters the program delays for a set time, determined by preference. I have it set for 1 minute. Read the comments in the code for more detailed information.

EDIT 12/7/13: In the original code, you must insert the morse for the call sign to be transmitted manually. In the updated (albeit messy, apologies) code, you just need to input the call and any other text in the string Text. For the program to transmit the easterEgg string instead, you must hold pin 10 high at reset. This is what qualifies the project for Hackaday's contest.
tytower11 months ago
Also not a good idea to put SOS out as a message and the long tone is a definate no no . So any newbies that take this up please don't foul up the airways. Governments love an excuse to take these things away and then charge a lot more to get them back.
tytower11 months ago
Test
tytower tytower11 months ago
Just looking to see what hoops I have to jump through here . Thankfully you can post without the crap.
I wonder if you would benefit from adoption of the array method used earlier and placed on hackaday a few weeks back. he had a unique way of using a bit array to return the morse . You simply altered the message needed by putting in the text , which I suppose would not be hard here either .
Thanks for the post
tytower tytower11 months ago
//
// Simple Arduino Morse Beacon
// Written by Mark VandeWettering K6HX
// Email: k6hx@arrl.net
struct t_mtab { char c, pat; } ;

struct t_mtab morsetab[] = {
{'.', 106},
{',', 115},
{'?', 76},
{'/', 41},
{'A', 6},
{'B', 17},
{'C', 21},
{'D', 9},
{'E', 2},
{'F', 20},
{'G', 11},
{'H', 16},
{'I', 4},
{'J', 30},
{'K', 13},
{'L', 18},
{'M', 7},
{'N', 5},
{'O', 15},
{'P', 22},
{'Q', 27},
{'R', 10},
{'S', 8},
{'T', 3},
{'U', 12},
{'V', 24},
{'W', 14},
{'X', 25},
{'Y', 29},
{'Z', 19},
{'1', 62},
{'2', 60},
{'3', 56},
{'4', 48},
{'5', 32},
{'6', 33},
{'7', 35},
{'8', 39},
{'9', 47},
{'0', 63}
} ;

#define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0]))

#define SPEED (10)
#define DOTLEN (1200/SPEED)
#define DASHLEN (3*(1200/SPEED))

int LEDpin = 13 ;
int Soundpin=9 ;

void
dash()
{
digitalWrite(LEDpin, HIGH) ;
analogWrite(9, 128);
delay(DASHLEN);
digitalWrite(LEDpin, LOW) ;
analogWrite(9, 0);
delay(DOTLEN) ;
}

void
dit()
{
digitalWrite(LEDpin, HIGH) ;
analogWrite(9, 128);
delay(DOTLEN);
digitalWrite(LEDpin, LOW) ;
analogWrite(9, 0);
delay(DOTLEN);
}

void
send(char c)
{
int i ;
if (c == ' ') {
Serial.print(c) ;
delay(7*DOTLEN) ;
return ;
}
for (i=0; i if (morsetab[i].c == c) {
unsigned char p = morsetab[i].pat ;
Serial.print(morsetab[i].c) ;

while (p != 1) {
if (p & 1)
dash() ;
else
dit() ;
p = p / 2 ;
}
delay(3*DOTLEN) ;
return ;
}
}
/* if we drop off the end, then we send a space */
Serial.print("?") ;
}

void
sendmsg(char *str)
{
while (*str)
send(*str++) ;
Serial.println("");
}

void setup() {
pinMode(LEDpin, OUTPUT) ;
pinMode(Soundpin,OUTPUT);
Serial.begin(9600) ;

}

void loop() {
sendmsg("CQ CQ DE VK4AAZ VK4AAZ K") ;
delay(6000) ;
}
jsmith2561 year ago
Cool project, looks like it is going to be used on a local foxhunt sometime soon.

A friend of mine suggested I feed back some changes I made. Took a few minutes to find you, but the power of the interwebz comes through!

When you do the sizeof you get double what you expect because the variable is declared int, which is a doublebyte construct. Change it to byte and you won't have to do the division.
...
byte code[] = { }; // 1 id dih, 2 is dah, 0 is pause
int codelength = sizeof(code);
...
I also changed the "rest" parameter by adding in a random element. My thought is you don't want the fox to be too predictable.
...
delay(rest+random(7000)); // keeps it from repeating on a regular schedule
...
It would be cool if the changes were attributed to me, but not necessary. These things are just too much fun.

Cheers,

Jim
hailster2 years ago
Thanks for posting this. I run the fox hunts for the local ham radio club (W9ZL) and currently use a really old stand alone fox, which I do not like because it was modified by someone in the past and I haven't been able to fully figure everything out. It's also fairly large so it isn't the easiest to hide.

I have a Arduino Uno laying around along with a IC-T90A that I don't use very often. This would be nice to use since it's smaller than the current transmitter and will allow us to also try doing a hunt on 70cm.
73,
KC9FSH
jstelmack2 years ago
Excellent FOX build! This gives me idea to expand into APRS use. Thanks! 73's