1
2#include "Keyboard.h"
3
11
12
13const int delete_buttonPin = 2;
14const int dash_buttonPin = 3;
15const int dot_buttonPin = 0;
16const int space_buttonPin = 1;
17const int new_line_buttonPin=7 ;
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,' ',
28'e','t',
29'i','a','n','m',
30's','u','r','w','d','k','g','o',
31'h','v','f',252,'l',228,'p','j','b','x','c','y','z','q',246,154,
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',
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,
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,
35};
36const int characters_array_limit=127;
37
38
39void setup() {
40
41
42pinMode(delete_buttonPin, INPUT);
43pinMode(dash_buttonPin, INPUT);
44pinMode(dot_buttonPin, INPUT);
45pinMode(space_buttonPin, INPUT);
46pinMode(new_line_buttonPin,INPUT);
47
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
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;}
62
63if (do_bk_space){Keyboard.write('\\b');do_bk_space=false;}
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
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