Introduction: USB Arduino Morse Code Key

Ever wanted to type on a computer with a morse code key or to learn/teach morse code? You are on the right page!

For my other projects, check out calvinliang.me

Step 1: Gather Materials

• 1 × Arduino/Genuino Micro

• 1 × 3v buzzer

• 1 × morse code key (I got this one: http://www.ebay.com/itm/Morse-code-straight-key-Made-in-Taiwan-/161178779257?hash=item258700fe79:g:aqEAAOxygPtSs5kk)

• 1 × 680Ω resistor

• 1 × 120Ω resistor

• 1 × circuit board

• 4 × M4×0.50 round head machine screws

• 2 × 6-32×1/2" round head machine screws

• 2 × 6-32 machine nuts

• Some mounting tape

• Some jumper wires

• You might also want to learn morse code if you don't already know

Step 2: Code

Upload the code to the Arduino/Genuino Micro

The Keyboard library allows the Arduino/Genuino Micro to act as a keyboard

In my code seven and eight dot("......." & "........") are backspace and a really long dash("-") is space

Step 3: Solder

Solder all the parts onto a perfboard.

I started the project knowing very little about Arduino. I used an analog pin to detect if the morse code key is clicked. You can use any analog or digital pin for this, just be sure to change the "morseKeyInputPin" in the code. If you know what you are doing, you can use the internal pullup(INPUT_PULLUP) resistor to detect the state of the morse code key.

Step 4: 3D Print the Base

You can order one from an online 3D printing service or print one yourself. The 3D model is designed with www.tinkercad.com, it's basically MS paint for 3D modeling.

Online 3D printing services:

www.sculpteo.com

www.shapeways.com

i.materialise.com

more on Google

Step 5: Assemble

1. Wire the two wires sticking out of the circuit board under the morse code key

2. Secure the morse code key onto the base with two 6-32×1/2" round head machine screws and 6-32 machine nuts

3. Tape the circuit board on to the bottom cover with mounting tape

4. Secure the bottom cover with the four M4×0.50 round head machine screws

5. Adjust the bottom screws/bolts to level the morse code key

Step 6: Start Typing

Here's a US navy training video on sending morse code

Plug it into your computer and start typing

Don't forget, in my code seven and eight dot("......." & "........") are backspace and a really long dash("-") is space

Comments

author
SamuelP32 (author)2016-05-30

Why did you use internel pulldown. Why could you not just use a 10k resistor.

author
CalvinL8 (author)SamuelP322016-05-30

Why wouldn't I use internal pulldown?

author
SamuelP32 (author)CalvinL82016-05-30

I made a mistake. There is no built in pulldown resistor. there is only a 20k resistor that can be used to pull it high but I would expect that you would not want to pull high, you want to pull low.

author
ThomasK19 (author)2016-03-05

Is there any reason you're reading the morse key analog? This is clearly a digital input, isn't it?

author
CalvinL8 (author)ThomasK192016-03-05

Nope, I use analog simply because I didn't know much about Arduino boards and that was the only way I know that can detect changes in voltage.

author
ThomasK19 (author)CalvinL82016-03-05

You can use digitalRead(pin) and it will return 0 or 1 (you can use symbolic names LOW and HIGH instead). You need to use a digital instead of an analog pin. Take any from 2 to 13 (0 and 1 are used for Serial). The digital pins have some hysteresis and will switch somewhere around 2.5 V to either 0 or 1. So if you connected your Morse switch to +5V and it pulls down to ground via a (say) 1k resistor you can directly read the digital values.

As a side note: the way you decoded the Morse code is fine. However, if you store it as binary tree you can go left or right at each short or long puls until you reach a leaf which tells you the found character. You might try coding it this way. It's a bit more challenging and also more esthetically :-)

author
CalvinL8 (author)ThomasK192016-03-05

I just changed the code, now it uses digitalRead instead of analogRead. I kept the array instead of using a binary tree so the code is more readable.

author
ThomasK19 (author)CalvinL82016-03-05

You have this alternative:

A) Change the morseInputPin to be 2 and connect the switch as shown in the picture (R is 1k) .

B) Change the morseInputPin to be 14 and leave the circuit as it is. A0 corresponds to digital input 14 (A1 = 15, etc.).

The Atmega is quite flexible.

pic 2016-03-06 um 00.18.56.PNG
author
CalvinL8 (author)ThomasK192016-03-05

You can also use the internal pullup resistor and just connect the other end to ground.

author
ThomasK19 (author)CalvinL82016-03-05

In that case you need to update the circuit accordingly. Since it connects to A0 it wont work with digitalRead.

author
CalvinL8 (author)ThomasK192016-03-05

digitalRead actually works with analog pin. see https://www.arduino.cc/en/Reference/DigitalRead

author
CalvinL8 (author)ThomasK192016-03-05

Good points, I am new to this. Didnt know you can do binary trees in Arduino.

author
ThomasK19 (author)CalvinL82016-03-05

Yeah. The binary tree is sort of a challenge ;-) You can code b-trees in all languages and there are plenty ways to do it in C (/Arduino). Just if you feel bored some time...

author
DIY Hacks and How Tos (author)2016-03-05

Nice! That is really cool. This would be great for teaching people how to use morse code.

author

Ya it is, I got three people interested in morse code the first day when I brought it to school.

About This Instructable

1,321views

34favorites

License:

More by CalvinL8:USB Arduino Morse Code Key
Add instructable to: