Morse-It
MIDI Hardware interface Sample
In Morse-it, it is possible to use a MIDI device as Morse input.
By default,
- for iAmbic Keys : the note number 18 is associated to the dit, and the note 38 to the dah.
- for Straight Keys : the note number 18 is associated to key.
You'll need :
- an Adafruit Trinket M0
- for recent iOS devices: a micro usb to usb cable
- for older iOS devices: a micro usb to usb cable and an usb to lightning adapter
- if necessary : an audio jack to connect your Key to the microcontroller.
![](TrinketM0.jpg)
I'm using the librairies adafruit_midi (only a subset of it is necessary), adafruit_debouncer, adafruit_ticks.
The following code has been tested with CircuitPython 9.1.1, so you might have to upgrade your circuitpython version (as explained here).
There are 2 specific python files to make this work :
-
code.py (the main code including a debouncer):
import usb_midi import adafruit_midi import board import digitalio from adafruit_debouncer import Debouncer from adafruit_midi.note_on import NoteOn from adafruit_midi.note_off import NoteOff midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=0) # Define the pins pin_left = digitalio.DigitalInOut(board.A3) pin_left.direction = digitalio.Direction.INPUT pin_left.pull = digitalio.Pull.UP switch_left = Debouncer(pin_left) pin_right = digitalio.DigitalInOut(board.A4) pin_right.direction = digitalio.Direction.INPUT pin_right.pull = digitalio.Pull.UP switch_right = Debouncer(pin_right) while True: switch_left.update() switch_right.update() if switch_left.fell: midi.send(NoteOn(18, 120)) if switch_left.rose: midi.send(NoteOff(18, 120)) if switch_right.fell: midi.send(NoteOn(38, 120)) if switch_right.rose: midi.send(NoteOff(38, 120))
-
boot.py (the code necessary to disable the keyboard feature):
import usb_hid usb_hid.disable()
Click here, to directly download an archive with the needed librairies and those 2 python files.
Unarchive the downloaded file, and put all the unarchived content directly on the disk of your Trinket MO:
(Move/Replace the code.py, boot.py files and lib folder to the root directory of the CIRCUITPI drive).
That's all!
you can now use Morse-it with your external key.