Devices & Components
Arduino Micro
Capacitor 100 nF
Pushbutton 6mm
Resistor 1k ohm
Capacitor 1uf Non-Electrolytic
Jumper wires (generic)
Breadboard Mini Modular 170 tiepoints
Capacitor 10 µF
74HCT14 (Hex Schmitt trigger NOT)
Resistor 82K
Solderless Breadboard Full Size
Reistor 18K
Software & Tools
Arduino IDE
Project description
Code
Morse keyboard code
c_cpp
1 2#include "Keyboard.h" 3/* 4//left handed -- checked 5const int delete_buttonPin = 0; // input pin for delete pushbutton 6const int dash_buttonPin = 3; // input pin for dash pushbutton 7const int dot_buttonPin = 2; // input pin for dot pushbutton 8const int space_buttonPin = 7; // input pin for space pushbutton 9const int new_line_buttonPin = 1; // input pin for new line pushbutton 10*/ 11 12//right handed 13const int delete_buttonPin = 2; // input pin for delete pushbutton 14const int dash_buttonPin = 3; // input pin for dash pushbutton 15const int dot_buttonPin = 0; // input pin for dot pushbutton 16const int space_buttonPin = 1; // input pin for space pushbutton 17const int new_line_buttonPin=7 ; // input pin for new line pushbutton 18 19 20volatile static bool do_new_line=false; 21volatile static bool do_bk_space=false; 22volatile static bool do_character=false; 23volatile static bool increment_dot=false; 24volatile static bool increment_dash=false; 25 26const unsigned char characters_array[]={ 270x00,' ',//positions 0 not used position 1 returns space character 28'e','t',//2 29'i','a','n','m',//4 30's','u','r','w','d','k','g','o',//8 31'h','v','f',252,'l',228,'p','j','b','x','c','y','z','q',246,154,//16 32'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 330x00,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 340x00,'-',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 35}; 36const int characters_array_limit=127;//128 characters so 0-127 37 38 39void setup() { 40 41// make the button pins input: 42pinMode(delete_buttonPin, INPUT); 43pinMode(dash_buttonPin, INPUT); 44pinMode(dot_buttonPin, INPUT); 45pinMode(space_buttonPin, INPUT); 46pinMode(new_line_buttonPin,INPUT); 47//assign interrupt handlers 48attachInterrupt(digitalPinToInterrupt(delete_buttonPin), bk_space,RISING ); 49attachInterrupt(digitalPinToInterrupt(dash_buttonPin), dash, RISING); 50attachInterrupt(digitalPinToInterrupt(dot_buttonPin), dot, RISING); 51attachInterrupt(digitalPinToInterrupt(space_buttonPin), space, RISING); 52attachInterrupt(digitalPinToInterrupt(new_line_buttonPin), new_line, RISING); 53// initialize control over the keyboard: 54Keyboard.begin(); 55} 56 57void loop() { 58 59static int characters_array_index=1; 60 61if (do_new_line){Keyboard.write('\n');do_new_line=false;}//new line character 62 63if (do_bk_space){Keyboard.write('\\b');do_bk_space=false;}//backspace character (for deletion) 64 65if (do_character){Keyboard.write((unsigned char)characters_array[characters_array_index]);characters_array_index=1;do_character=false; } 66 67if(increment_dot){if ((characters_array_index*2)>characters_array_limit){increment_dot=false;do_character=true;} 68 else {characters_array_index=characters_array_index*2;increment_dot=false;} } 69 70if(increment_dash){if (((characters_array_index*2)+1)>characters_array_limit){increment_dash=false;do_character=true;} 71 else {characters_array_index=(characters_array_index*2)+1;increment_dash=false;} } 72 73} 74 75//my_interrupt_functions 76void dot(void) {increment_dot=true;} 77void dash(void) {increment_dash=true;} 78void space(void) {do_character=true;} 79void bk_space(void) {do_bk_space=true;} 80void new_line(void) {do_new_line=true;} 81
Downloadable files
Breadboard layout morse keyboard
Breadboard layout morse keyboard

Debounce circuit schematic
Debounce circuit schematic
Breadboard layout morse keyboard
Breadboard layout morse keyboard

Debounce circuit schematic
Debounce circuit schematic
Comments
Only logged in users can leave comments