Sunday, 1 June 2014

Fun little project at GB5BRA Banbury Show

The Banbury Amateur Radio Society will be at the annual Banbury show on Sunday 8th June. We will be operating a station GB5BRA and look forward to contacting you...

Also at the show we will be promoting amateur radio. For this we have a display panel "LEARN _ BUILD _ PLAY". And a tiny demo using an Arduino to send an automated morse message "CQ CQ CQ DE GB5BRA GB5BRA K".

Circuit

Screen Shot 2014 06 02 at 09 19 15 Here's the code:

// Morse transmitter, with oscillator 
// LED & OSC Pin 7

// output pin
#define LEDPIN 7

// text array codes
#define DOT 0
#define DASH 1
#define SPACE 2
#define WORD 3

// message words
int CQ[] = {1,0,1,0,2,1,1,0,1,3};
int DE[] = {1,0,0,2,0,3};
int GB5BRA[] = {1,1,0,2,1,0,0,0,2,0,0,0,0,0,2,1,0,0,0,2,0,1,0,2,0,1,3};
int K[] = {1,0,1,3};

// dash = 3 dots, space = 3 dots, word = 7 dots
#define DOTTIME 150

void setup() 
{
  pinMode(LEDPIN, OUTPUT);
}

void loop() 
{

// send message words, sends CQ CQ CQ DE GB5BRA GB5BRA K
  sender(CQ);
  sender(CQ);
  sender(CQ);
  sender(DE);
  sender(GB5BRA);
  sender(GB5BRA);
  sender(K);
  
  delay(2000); // repeat after 2 secs
}

// send a word
void sender(int dida[]) {

  int x = 0; // array index

// send characters up to end of word
  while(dida[x] != WORD) {
   switch (dida[x]) {
    case DOT:
       transmit(DOTTIME);
       delay(DOTTIME); // add after dot
       break;
    case DASH:
        transmit(3 * DOTTIME);
        delay(DOTTIME); // add after dash
        break;
    case SPACE:
         delay(2 * DOTTIME);  // add for space
         break;
    }
    x++;
  }
  delay(6 * DOTTIME); // add   for word
}

// transmit for time (msec)
void transmit(long time) {

  digitalWrite(LEDPIN, HIGH); // turn on LED
  delay(time); // time 
  digitalWrite(LEDPIN, LOW); // turn off LED
}



Update: Its a pity but the Banbury Show, where the project would be shown, was cancelled 3 days before it was due, because of a water logged field.

No comments: