glennedi
Published © GPL3+

Morse Keyboard

A novel input device implemented with a binary tree.

IntermediateFull instructions provided2,740
Morse Keyboard

Things used in this project

Hardware components

Resistor 82K
×5
Reistor 18K
×5
Resistor 1k ohm
Resistor 1k ohm
×1
Capacitor 1uf Non-Electrolytic
×5
Capacitor 10 µF
Capacitor 10 µF
×1
Capacitor 100 nF
Capacitor 100 nF
×1
74HCT14 (Hex Schmitt trigger NOT)
×1
Pushbutton 6mm
×5
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Breadboard Mini Modular 170 tiepoints
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Arduino Micro
Arduino Micro
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Breadboard layout morse keyboard

Debounce circuit schematic

Code

Morse keyboard code

C/C++
    
#include "Keyboard.h"
/*
//left handed -- checked
const int delete_buttonPin = 0;          // input pin for delete pushbutton
const int dash_buttonPin = 3;            // input pin for dash pushbutton
const int dot_buttonPin = 2;             // input pin for dot pushbutton
const int space_buttonPin = 7;           // input pin for space pushbutton
const int new_line_buttonPin = 1;          // input pin for new line pushbutton
*/

//right handed
const int delete_buttonPin = 2;          // input pin for delete pushbutton
const int dash_buttonPin = 3;            // input pin for dash pushbutton
const int dot_buttonPin = 0;             // input pin for dot pushbutton
const int space_buttonPin = 1;           // input pin for space pushbutton
const int new_line_buttonPin=7 ;          // input pin for new line pushbutton


volatile static bool do_new_line=false;
volatile static bool do_bk_space=false;
volatile static bool do_character=false;
volatile static bool increment_dot=false;
volatile static bool increment_dash=false;

const unsigned char characters_array[]={
0x00,' ',//positions 0 not used position 1 returns space character
'e','t',//2
'i','a','n','m',//4
's','u','r','w','d','k','g','o',//8
'h','v','f',252,'l',228,'p','j','b','x','c','y','z','q',246,154,//16
'5','4','S','3',233,0x00,208,'2',0x00,232,'+',0x00,254,224,'J','1','6','=','/',0x00,231,0x00,'(',0x00,'7',0x00,'G',241,'8',0x00,'9','0',//32
0x00,0x00,0x00,0x00,'$',0x00,0x00,0x00,0x00,0x00,0x00,0x00,'?','_',0x00,0x00,0x00,0x00,'"',0x00,0x00,'.',0x00,0x00,0x00,0x00,'@',0x00,0x00,0x00,39,0x00,//64 part 1
0x00,'-',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,';','!',0x00,')',0x00,0x00,0x00,0x00,0x00,',',0x00,0x00,0x00,0x00,':',0x00,0x00,0x00,0x00,0x00,0x00,0x00,//64 part 2
};
const int characters_array_limit=127;//128 characters so 0-127


void setup() {
  
// make the button pins input:
pinMode(delete_buttonPin, INPUT);
pinMode(dash_buttonPin, INPUT);
pinMode(dot_buttonPin, INPUT);
pinMode(space_buttonPin, INPUT);
pinMode(new_line_buttonPin,INPUT);
//assign interrupt handlers
attachInterrupt(digitalPinToInterrupt(delete_buttonPin), bk_space,RISING );
attachInterrupt(digitalPinToInterrupt(dash_buttonPin), dash, RISING);
attachInterrupt(digitalPinToInterrupt(dot_buttonPin), dot, RISING);
attachInterrupt(digitalPinToInterrupt(space_buttonPin), space, RISING);
attachInterrupt(digitalPinToInterrupt(new_line_buttonPin), new_line, RISING);        
// initialize control over the keyboard:
Keyboard.begin();
}

void loop() {

static int characters_array_index=1;

if (do_new_line){Keyboard.write('\n');do_new_line=false;}//new line character

if (do_bk_space){Keyboard.write('\b');do_bk_space=false;}//backspace character (for deletion)

if (do_character){Keyboard.write((unsigned char)characters_array[characters_array_index]);characters_array_index=1;do_character=false; }

if(increment_dot){if ((characters_array_index*2)>characters_array_limit){increment_dot=false;do_character=true;} 
                        else {characters_array_index=characters_array_index*2;increment_dot=false;} }

if(increment_dash){if (((characters_array_index*2)+1)>characters_array_limit){increment_dash=false;do_character=true;} 
                        else {characters_array_index=(characters_array_index*2)+1;increment_dash=false;} }
                        
}

//my_interrupt_functions 
void dot(void) {increment_dot=true;}
void dash(void) {increment_dash=true;}
void space(void) {do_character=true;}
void bk_space(void) {do_bk_space=true;}
void new_line(void) {do_new_line=true;}

Credits

glennedi

glennedi

5 projects • 23 followers

Comments