Pages: [1]   Go Down
Author Topic: Semi-automatic morse code keyer  (Read 821 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been lurking here for a while but I've found something I want to share that I haven't seen anywhere else.  It is a semi-automatic keyer for morse code.

A keyer uses two small paddles, one for the thumb, the other for the middle knuckle of the index finger.  The thumb's paddle creates an endless series of 'dits' when pressed, while the index finger's produces 'dahs' for as long as it is held.  When both are held and alternating stream of dit-dat-dit-dah is created.

I intend to combine this code with an interpreter so I can see what I send (for training purposes).
Code:
// Semiautomatic keyer
// By Greg Clements
/*
Circuit setup:
Digital pin 2 is the 'dit' (single unit element), typically this is the left paddle on the keyer.
Digital pin 3 is the 'dah' (three unit element), typically this is the right paddle on the keyer.
buttons/switches for pins 2 and 3 should pull down when active (as the internal pullup resistors are used)
Digital pin 12 outputs a 490hz square wave tone during each symbol. (50% duity cycle)
Digital pin 13 outputs a solid 5v pulse for the duration of each symbol.

time per element is defined by unitMS in milliseconds, to calculate this value for your prefered speed use the following:
unitMS = 1200 / (words per minute)
or
unitsMS = 6000 / (characters per minute)
Note: feel free to modify this program to use a potentiometer and an analog input to replace this calculation, a value between 0 and 255
should meet almost anybody's needs.
*/
#define unitMS 240

void setup() {
  pinMode(2, INPUT);  //Dit input (left button)
  digitalWrite(2, HIGH);  //Set pullup resistor
  pinMode(3, INPUT);  //Dah input  (right button)
  digitalWrite(3, HIGH);  //Set pullup resistor
  pinMode(12, OUTPUT);  //PWM output
  pinMode(13, OUTPUT);  //Logic outputf
}

void ON()
{
   analogWrite(12,128);
   digitalWrite(13, HIGH);
}
void OFF()
{
  analogWrite(12,0);
  digitalWrite(13, LOW);
}

void dit()  //play tone for one unit
{
  ON();
  delay(unitMS);
  OFF();
}

void dah()
{
  ON();
  delay(unitMS);
  delay(unitMS);
  delay(unitMS);
  OFF();
}

void space()
{
  delay(unitMS);
}

void loop() {
  if (!digitalRead(2)) {
    dit();
    space();
  }
  if (!digitalRead(3)) {
    dah();
    space();
  }
}

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just what I've been looking for...
Thanks smiley
Logged

Pages: [1]   Go Up
Jump to: