// braille keyboard - Serial version // Created by, Haydn Jones 2017 // Creative commons licence (CC BY 4.0) //https://creativecommons.org/licenses/by/4.0/ // Do whatever you like with the code, just credit me please ) // thanks to hackaday.io user [Arsenijs] for helping me debug my code :) // braille keyboard // braille dot numbering // (1) (4) // (2) (5) // (3) (6) // keyboard layout // [delete] [3] [2] [1] [4] [5] [6] [enter] // [space] // setup keys and pins, key names based on braille standard const int deleteKey = 2; const int enterKey = 3; const int spaceKey = 4; const int Key3 = 5; const int Key2 = 6; const int Key1 = 7; const int Key4 = 8; const int Key5 = 9; const int Key6 = 10; // create states for character keys long state3,state2,state1,state4,state5,state6 ; long statetotal ; long capitolsingle ; long number ; int deleteKeyVal = 0; int enterKeyVal = 0; int spaceKeyVal = 0; int Key3Val = 0; int Key2Val = 0; int Key1Val = 0; int Key4Val = 0; int Key5Val = 0; int Key6Val = 0; void setup() { // setup keys as inputs pinMode(deleteKey, INPUT_PULLUP); pinMode(enterKey, INPUT_PULLUP); pinMode(spaceKey, INPUT_PULLUP); pinMode(Key3, INPUT_PULLUP); pinMode(Key2, INPUT_PULLUP); pinMode(Key1, INPUT_PULLUP); pinMode(Key4, INPUT_PULLUP); pinMode(Key5, INPUT_PULLUP); pinMode(Key6, INPUT_PULLUP); } void loop() { // put your main code here, to run repeatedly: deleteKeyVal = digitalRead(deleteKey); // read INPUT value enterKeyVal = digitalRead(enterKey); spaceKeyVal = digitalRead(spaceKey); Key3Val = digitalRead(Key3); Key2Val = digitalRead(Key2); Key1Val = digitalRead(Key1); Key4Val = digitalRead(Key4); Key5Val = digitalRead(Key5); Key6Val = digitalRead(Key6); //debug //Keyboard.print(enterKeyVal); //Keyboard.println(spaceKeyVal); //detect key presses if (deleteKeyVal == LOW) { deletepress(); } if (enterKeyVal == LOW) { enterpress(); } if (spaceKeyVal == LOW) { spacepress(); } // aplies a numerical value to pushed braille keys to be mapped to ascii if (Key3Val == LOW) { state3=1 ; } if (Key2Val == LOW) { state2=2; } if (Key1Val == LOW) { state1=4 ; } if (Key4Val == LOW) { state4=8 ; } if (Key5Val == LOW) { state5=16 ; } if (Key6Val == LOW) { state6=32; } if (Key3Val == HIGH && Key2Val == HIGH && Key1Val == HIGH && Key4Val == HIGH && Key5Val == HIGH && Key6Val == HIGH) { characters(); } } void enterpress() { Keyboard.println(""); while (enterKeyVal == HIGH); } void deletepress() { Keyboard.write(127); } void spacepress() { Keyboard.print(" "); while (spaceKeyVal == HIGH); number=0; } void characters() { statetotal=state3+state2+state1+state4+state5+state6; if (capitolsingle == 1){ capitols(); } if (number == 1){ numbers(); } //prints value for each state if (statetotal == 1) { } if (statetotal == 2){ Keyboard.print(","); } if (statetotal == 3){ } if (statetotal == 4){ Keyboard.print("a"); } if (statetotal == 5){ Keyboard.print("k"); } if (statetotal == 6){ Keyboard.print("b"); } if (statetotal == 7){ Keyboard.print("l"); } if (statetotal == 8){ } if (statetotal == 9){ } if (statetotal == 10){ Keyboard.print("i"); } if (statetotal == 11){ Keyboard.print("s"); } if (statetotal == 12){ Keyboard.print("c"); } if (statetotal == 13){ Keyboard.print("m"); } if (statetotal == 14){ Keyboard.print("f"); } if (statetotal == 15){ Keyboard.print("p"); } if (statetotal == 16){ } if (statetotal == 17){ } if (statetotal == 18){ } if (statetotal == 19){ } if (statetotal == 20){ Keyboard.print("e"); } if (statetotal == 21){ Keyboard.print("o"); } if (statetotal == 22){ Keyboard.print("h"); } if (statetotal == 23){ Keyboard.print("r"); } if (statetotal == 24){ } if (statetotal == 25){ } if (statetotal == 26){ Keyboard.print("j"); } if (statetotal == 27){ Keyboard.print("b"); } if (statetotal == 28){ Keyboard.print("d"); } if (statetotal == 29){ Keyboard.print("n"); } if (statetotal == 30){ Keyboard.print("g"); } if (statetotal == 31){ Keyboard.print("q"); } if (statetotal == 32){ capitolsingle=1; } if (statetotal == 33){ } if (statetotal == 34){ } if (statetotal == 35){ } if (statetotal == 36){ } if (statetotal == 37){ Keyboard.print("u"); } if (statetotal == 38){ } if (statetotal == 39){ Keyboard.print("v"); } if (statetotal == 40){ } if (statetotal == 41){ } if (statetotal == 42){ } if (statetotal == 43){ } if (statetotal == 44){ } if (statetotal == 45){ Keyboard.print("x"); } if (statetotal == 46){ } if (statetotal == 47){ } if (statetotal == 48){ } if (statetotal == 49){ } if (statetotal == 50){ Keyboard.print("."); } if (statetotal == 51){ } if (statetotal == 52){ } if (statetotal == 53){ Keyboard.print("z"); } if (statetotal == 54){ } if (statetotal == 55){ } if (statetotal == 56){ } if (statetotal == 57){ number=1; } if (statetotal == 58){ Keyboard.print("w"); } if (statetotal == 59){ } if (statetotal == 60){ } if (statetotal == 61){ Keyboard.print("y"); } if (statetotal == 62){ } if (statetotal == 63){ } // resets states // set key states to 0 state3=0; state2=0; state1=0; state4=0; state5=0; state6=0; statetotal=0; delay(200); } // void capitols(){ if (statetotal == 1) { } if (statetotal == 4){ Keyboard.print("A"); } if (statetotal == 5){ Keyboard.print("K"); } if (statetotal == 6){ Keyboard.print("B"); } if (statetotal == 7){ Keyboard.print("L"); } if (statetotal == 10){ Keyboard.print("I"); } if (statetotal == 11){ Keyboard.print("S"); } if (statetotal == 12){ Keyboard.print("C"); } if (statetotal == 13){ Keyboard.print("M"); } if (statetotal == 14){ Keyboard.print("F"); } if (statetotal == 15){ Keyboard.print("P"); } if (statetotal == 20){ Keyboard.print("E"); } if (statetotal == 21){ Keyboard.print("O"); } if (statetotal == 22){ Keyboard.print("H"); } if (statetotal == 23){ Keyboard.print("R"); } if (statetotal == 26){ Keyboard.print("J"); } if (statetotal == 27){ Keyboard.print("B"); } if (statetotal == 28){ Keyboard.print("D"); } if (statetotal == 29){ Keyboard.print("N"); } if (statetotal == 30){ Keyboard.print("G"); } if (statetotal == 31){ Keyboard.print("Q"); } if (statetotal == 37){ Keyboard.print("U"); } if (statetotal == 39){ Keyboard.print("V"); } if (statetotal == 45){ Keyboard.print("X"); } if (statetotal == 53){ Keyboard.print("Z"); } if (statetotal == 58){ Keyboard.print("W"); } if (statetotal == 61){ Keyboard.print("Y"); } // resets states // set key states to 0 state3=0; state2=0; state1=0; state4=0; state5=0; state6=0; statetotal=0; capitolsingle=0; delay(200); } void numbers(){ if (statetotal == 1) { } if (statetotal == 4){ Keyboard.print("1"); } if (statetotal == 6){ Keyboard.print("2"); } if (statetotal == 10){ Keyboard.print("9"); } if (statetotal == 12){ Keyboard.print("3"); } if (statetotal == 14){ Keyboard.print("6"); } if (statetotal == 20){ Keyboard.print("5"); } if (statetotal == 22){ Keyboard.print("8"); } if (statetotal == 26){ Keyboard.print("0"); } if (statetotal == 28){ Keyboard.print("4"); } if (statetotal == 30){ Keyboard.print("7"); } // resets states // set key states to 0 state3=0; state2=0; state1=0; state4=0; state5=0; state6=0; statetotal=0; capitolsingle=0; delay(200); } //111112 aaaa,aaaaaaaaaaa aaaa //ab12aaabbbba // //aa //aa