So used UltraEdit for columwise editing the website table
then used LibreOffice to create the array
and di d some refinements to the code
// MACRO-START * MACRO-START * MACRO-START * MACRO-START * MACRO-START * MACRO-START *
// Take it for granted at the moment scroll down to void setup
// start of macros dbg and dbgi
#define dbg(myFixedText, variableName) \
Serial.print( F(#myFixedText " " #variableName"=") ); \
Serial.println(variableName);
// usage: dbg("1:my fixed text",myVariable);
// myVariable can be any variable or expression that is defined in scope
#define dbgi(myFixedText, variableName,timeInterval) \
do { \
static unsigned long intervalStartTime; \
if ( millis() - intervalStartTime >= timeInterval ){ \
intervalStartTime = millis(); \
Serial.print( F(#myFixedText " " #variableName"=") ); \
Serial.println(variableName); \
} \
} while (false);
// usage: dbgi("2:my fixed text",myVariable,1000);
// myVariable can be any variable or expression that is defined in scope
// third parameter is the time in milliseconds that must pass by until the next time a
// Serial.print is executed
// end of macros dbg and dbgi
// print only once when value has changed
#define dbgc(myFixedText, variableName) \
do { \
static long lastState; \
if ( lastState != variableName ){ \
Serial.print( F(#myFixedText " " #variableName" changed from ") ); \
Serial.print(lastState); \
Serial.print( F(" to ") ); \
Serial.println(variableName); \
lastState = variableName; \
} \
} while (false);
// MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END * MACRO-END *
// Arduino UserInput, with LEDs
constexpr byte Leds[] {3, 4, 5, 6, 7, 8};
struct Letter2Braille_type {
char letter;
byte brailleDots[6]; // 6 elements with index-numbers 0,1,2,3,4,5
};
// this array has the letters as an element of a struct
// this means the order in which the elements are defined
// is irrelevant if all elements are crawled through with
// a for-loop
Letter2Braille_type myLetter2BrailleArray[]
{
{ .letter = ' ',
0, 0,
0, 0,
0, 0
},
{ .letter = '!',
0, 1,
1, 1,
0, 1
},
{ .letter = '"',
0, 0,
0, 0,
1, 0
},
{ .letter = '#',
0, 0,
1, 1,
1, 1
},
{ .letter = '$',
1, 1,
0, 1,
0, 1
},
{ .letter = '%',
1, 0,
0, 1,
0, 1
},
{ .letter = '&',
1, 1,
1, 1,
0, 1
},
{ .letter = '\'',
0, 0,
1, 0,
0, 0
},
{ .letter = '(',
1, 1,
1, 0,
1, 1
},
{ .letter = ')',
0, 1,
1, 1,
1, 1
},
{ .letter = '*',
1, 0,
0, 0,
0, 1
},
{ .letter = '+',
0, 0,
1, 1,
0, 1
},
{ .letter = ',',
0, 0,
0, 0,
0, 1
},
{ .letter = '-',
0, 0,
1, 0,
0, 1
},
{ .letter = '.',
0, 0,
0, 1,
0, 1
},
{ .letter = '/',
0, 0,
1, 1,
0, 0
},
{ .letter = '0',
0, 0,
1, 0,
1, 1
},
{ .letter = '1',
0, 1,
0, 0,
0, 0
},
{ .letter = '2',
0, 1,
1, 0,
0, 0
},
{ .letter = '3',
0, 1,
0, 0,
1, 0
},
{ .letter = '4',
0, 1,
0, 0,
1, 1
},
{ .letter = '5',
0, 1,
0, 0,
0, 1
},
{ .letter = '6',
0, 1,
1, 0,
1, 0
},
{ .letter = '7',
0, 1,
1, 0,
1, 1
},
{ .letter = '8',
0, 1,
1, 0,
0, 1
},
{ .letter = '9',
0, 0,
1, 0,
1, 0
},
{ .letter = ':',
1, 0,
0, 0,
1, 1
},
{ .letter = ';',
0, 0,
0, 0,
1, 1
},
{ .letter = '<',
1, 1,
0, 0,
0, 1
},
{ .letter = '=',
1, 1,
1, 1,
1, 1
},
{ .letter = '>',
0, 0,
1, 1,
1, 0
},
{ .letter = '?',
1, 0,
0, 1,
1, 1
},
{ .letter = '@',
0, 0,
0, 1,
0, 0
},
{ .letter = 'A',
1, 0,
0, 0,
0, 0
},
{ .letter = 'B',
1, 1,
0, 0,
0, 0
},
{ .letter = 'C',
1, 0,
0, 1,
0, 0
},
{ .letter = 'D',
1, 0,
0, 1,
1, 0
},
{ .letter = 'E',
1, 0,
0, 0,
1, 0
},
{ .letter = 'F',
1, 1,
0, 1,
0, 0
},
{ .letter = 'G',
1, 1,
0, 1,
1, 0
},
{ .letter = 'H',
1, 1,
0, 0,
1, 0
},
{ .letter = 'I',
0, 1,
0, 1,
0, 0
},
{ .letter = 'J',
0, 1,
0, 1,
1, 0
},
{ .letter = 'K',
1, 0,
1, 0,
0, 0
},
{ .letter = 'L',
1, 1,
1, 0,
0, 0
},
{ .letter = 'M',
1, 0,
1, 1,
0, 0
},
{ .letter = 'N',
1, 0,
1, 1,
1, 0
},
{ .letter = 'O',
1, 0,
1, 0,
1, 0
},
{ .letter = 'P',
1, 1,
1, 1,
0, 0
},
{ .letter = 'Q',
1, 1,
1, 1,
1, 0
},
{ .letter = 'R',
1, 1,
1, 0,
1, 0
},
{ .letter = 'S',
0, 1,
1, 1,
0, 0
},
{ .letter = 'T',
0, 1,
1, 1,
1, 0
},
{ .letter = 'U',
1, 0,
1, 0,
0, 1
},
{ .letter = 'V',
1, 1,
1, 0,
0, 1
},
{ .letter = 'W',
0, 1,
0, 1,
1, 1
},
{ .letter = 'X',
1, 0,
1, 1,
0, 1
},
{ .letter = 'Y',
1, 0,
1, 1,
1, 1
},
{ .letter = 'Z',
1, 0,
1, 0,
1, 1
},
{ .letter = '[',
0, 1,
0, 1,
0, 1
},
{ .letter = '\\',
1, 1,
0, 0,
1, 1
},
{ .letter = ']',
1, 1,
0, 1,
1, 1
},
{ .letter = '^',
0, 0,
0, 1,
1, 0
},
{ .letter = '_',
0, 0,
0, 1,
1, 1
} // last one is WITHOUT comma
};
String askStr = "Enter a word or number from 20 Characters: ";
void SetLEDsAndPrint(byte p_myIdx) {
int element = 0;
// the "0" and "1" are comming from READING the IO-pin
// this means you read in the REAL IO-state of the IO-pins
for (byte LedNr = 0; LedNr < 6; LedNr++ ) {
digitalWrite(Leds[LedNr], myLetter2BrailleArray[p_myIdx].brailleDots[LedNr]);
// this lines make visible in the serial monitor what is going on
Serial.print("Leds[");
Serial.print(LedNr);
Serial.print("]=");
Serial.println( digitalRead(Leds[LedNr]) );
}
// this for-loop prints the braille-dots in dot-order
Serial.println("Braille-Dots");
for (byte LedNr = 0; LedNr < 6; LedNr += 2 ) {
Serial.print(digitalRead(Leds[LedNr]) );
Serial.print(" ");
Serial.println(digitalRead(Leds[LedNr + 1]) );
}
}
int findIndexNrOfChar(char p_myChar) {
// no of bytes of complete array / number of bytes of one array-element
// result= number of array-elements
byte MaxIdx (sizeof(myLetter2BrailleArray) / (sizeof(myLetter2BrailleArray[0])) );
//dbg("M:", MaxIdx );
// iterate through array to find matching character
for (byte Idx = 0; Idx < MaxIdx; Idx++) {
if (myLetter2BrailleArray[Idx].letter == p_myChar) {
return Idx; // if character is found return with Indexnumber of this character
}
}
return -1; // if character is not found return -1
}
void setup() {
Serial.begin(115200);
Serial.println( F("Setup-Start") );
for (byte LedNr = 0; LedNr < 6; LedNr++ ) {
pinMode(Leds[LedNr], OUTPUT);
}
Serial.println(askStr);
}
void loop() {
while (Serial.available() == 0) {}
if (Serial.available() != 0) {
char inChar = Serial.read();
inChar = toupper(inChar);
if (inChar >= ' ' ) { // only in case the received character is printable
Serial.print("received character #");
Serial.print(inChar);
Serial.println("#");
for (byte LedNr = 0; LedNr < 6; LedNr++ ) {
digitalWrite(Leds[LedNr], LOW);
}
int IDX = findIndexNrOfChar(inChar);
dbgc("I:",IDX);
if (IDX >= 0) { // if character is found
SetLEDsAndPrint(IDX);
delay(1500);
}
Serial.println(askStr);
}
}
}