Morse sender

My local radio amateur club asked for at little design to show the call sign – OZ7RD – of the club in morse.
It sends a 30 sec “beacon” with output on and speaker of, then sends the callsign in morse to the output and the speaker.

It is aimed to power a large 12V LED so the output has a MOSFET.
The board has a small blue LED and a speaker for demonstration use.
It is possible to adjust the morse speed by two straps, so the dot length can be made 80, 120, 160 or 200 msec.
Another strap selects if a delay between transmission of 2 or 4 secs is wanted.

I made this in a little circuit with a ATtiny85 programmed in Arduino.
The ATtiny85 chip is programmed by a USBasp programmer.

Here is the prototype:
Here the schematic:

And here in PDF: Morse_t85_sch_211203
I made a board layout, but I have not got it made, only a prototype exist:
And here the Arduino sketch:
/* MORSE code translator 08.12.2021 with ATtiny85, Hans Harbeck */

String CallSign = "OZ7RD";
#define TONE
#define Delay0 1000   // Delay before and after morse transmission
#define Delay1 30000  // Output ON time (beacon 30 sec)
// DOT length in msek, jumper definitions JP1-JP2, see schematic
#define Speed0 200   // JP1 off, JP2 off
#define Speed1 160   // JP1  on, JP2 off
#define Speed2 120   // JP1 off, JP2  on 
#define Speed3 80    // JP1  on, JP2  on

// ATtiny85 pin definitions
#define LedPin     0   // pin 5
#define SpeakerPin 1   // pin 6
#define SpeedPin1  3   // pin 2, morse speed middle
#define SpeedPin2  4   // pin 3, morse speed high
#define DelayPin   2   // pin 7, delay  off = 2 sec, on = 4 sec
//                  +-\/-+
// Ain0 (D 5) PB5  1|    |8  Vcc
// Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1 
// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//            GND  4|    |5  PB0 (D 0) pwm0
//                  +----+

unsigned int dotDelay; // morse speed
unsigned int pause;    // delay between transmissions
// se explanation af tone creation here:  http://www.technoblogy.com/show?KVO

//For letters
char* letters[] = {
  ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",    // A-I
  ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",  // J-R 
  "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."          // S-Z
};

//For Numbers
char* numbers[] = {
  "-----", ".----", "..---", "...--", "....-",  // 0-4
  ".....","-....", "--...", "---..", "----."    // 5-9
};


void setup() {  // -----------------------------------
  pinMode(LedPin, OUTPUT);
  pinMode(SpeakerPin, OUTPUT);
  pinMode(SpeedPin1, INPUT_PULLUP);
  pinMode(SpeedPin2, INPUT_PULLUP);
  pinMode(DelayPin, INPUT_PULLUP);    // not used
  CallSign.toUpperCase();
}

void loop() {  // ------------------------------------
  bool Pin1 = digitalRead(SpeedPin1);
  bool Pin2 = digitalRead(SpeedPin2);
  if (Pin1 == 1 && Pin2 == 1) dotDelay = Speed0;
  if (Pin1 == 0 && Pin2 == 1) dotDelay = Speed1;
  if (Pin1 == 1 && Pin2 == 0) dotDelay = Speed2;
  if (Pin1 == 0 && Pin2 == 0) dotDelay = Speed3;

//  if (digitalRead(DelayPin)) pause = Delay1;    // jumper off
//  else pause = Delay0;    // jumper on
  
  char ch;
  for (byte i = 0; i < CallSign.length(); i++) {
    ch = CallSign[i];
    if (ch >= 'A' && ch <= 'Z')  flashSequence(letters[ch - 'A']);
    else if (ch >= '0' && ch <= '9')  flashSequence(numbers[ch - '0']);
    else if (ch == ' ')   delay(dotDelay * 4);
  }

  pause = Delay0;
  delay (pause); // delay between morse and beacon
  OutOn(0);
  pause = Delay1;
  delay (pause); // beacon time
  OutOff();
  pause = Delay0;
  delay (pause); // delay between beacon and morse
}


// send one character
void flashSequence(char* sequence) {
  byte i = 0;
  while (sequence[i] != 0) {
    flashDotOrDash(sequence[i]);
    i++;
  }
  delay(dotDelay * 3);
}

// send . or -
void flashDotOrDash(char dotOrDash) {
  OutOn(1);
  if (dotOrDash == '.') delay(dotDelay);  // . dot
  else delay(dotDelay * 3);  // must be a - dash
  OutOff();
  delay(dotDelay);
}

void OutOn (bool HT) {
  digitalWrite(LedPin, HIGH);
#ifdef TONE
  if (HT) {
    TCCR1 = 0x90 | (3);  // start playing a tone
    OCR1C = 141;         // set the OCR
  }
#else
  digitalWrite(SpeakerPin, HIGH);
#endif
}

void OutOff () {
  digitalWrite(LedPin, LOW);
#ifdef TONE
  TCCR1 = 0x90;              // stop the tone counter
#else
  digitalWrite(SpeakerPin, LOW);
#endif
}

 

 

Min private hjemmeside