Sunday, June 24, 2012

Update to the PTT Mic via USB Project

So since I've gotten into trying to learn Morse code, I needed some type of oscillator, so that I can hear my key as I practice.  You can purchase an oscillator from companies like MFJ, or you can make the on the cheap with a piezoelectric buzzer and a 9v battery.  I chose a slightly different route.

My option was to add a 1/4" jack to my PTT desk mic via USB project box.  I did keep the piezo buzzer in case I wanted to practice without interacting with the PC, but I am currently using a program called MorseRabbit, which can accept input from the keyboard spacebar.  Only, in this instance, the input is coming from my straight key, which in turn is connected to the Teensy USB microcontroller, which is emulating a keyboard.

My Parts List:

  • 1/4" mono audio jack (panel mount)
  • 5v piezo buzzer
  • bit of wire and solder
Time to Completion:
  • 30 minutes, including adding the necessary code to the "sketch"
Here is a pic:



Here is a copy of the code "sketch" that I am using:

#include <Bounce.h>

Bounce button0 = Bounce(0, 10);
Bounce button1 = Bounce(1, 10);

void setup() {
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(12, OUTPUT);
  pinMode(14, OUTPUT);
}

void loop() {
  // Update all the buttons.  There should not be any long
  // delays in loop(), so this runs repetitively at a rate
  // faster than the buttons could be pressed and released.
  button0.update();
  button1.update();

if (button0.fallingEdge()) {
   // press and release CTRL
   Keyboard.set_key1(KEYPAD_PLUS);
   Keyboard.send_now();
   Keyboard.set_key1(0);
   Keyboard.send_now();
   analogWrite(12, 200);
  }

 if (button0.risingEdge()) {
   // press and release CTRL
   Keyboard.set_key1(KEYPAD_PLUS);
   Keyboard.send_now();
   Keyboard.set_key1(0);
   Keyboard.send_now();
   analogWrite(12, 0);
  }
  
if (button1.fallingEdge()) {
   // press and hold space
   Keyboard.set_key1(KEY_SPACE);
   Keyboard.send_now();
   analogWrite(12, 200);
   //analogWrite(14, 255);
  }

 if (button1.risingEdge()) {
   // release space
   Keyboard.set_key1(KEY_SPACE);
   Keyboard.set_key1(0);
   Keyboard.send_now();
   analogWrite(12, 0);
   //analogWrite(14, 0);
  }  
}


You have to forgive the sloppy wiring, it was too much hassle for this project to etch a pc board.  Now I have the ability to practice CW on my PC, both sending and copying!

73,

Richard, KK4JDO


No comments:

Post a Comment