Hey, I’m new to using forums but have been told by my fellow student friends that it is the best way to get support on Arduino programming.
I have a uni project which involves using an Arduino to control some micro push solenoids on a refreshable diaply. The solenoids will display a predefined message in Braille.
I am trying to break down the project the best I can so firstly I have arranged 6 led’s on a breadboard each one representing the 6 pins from a braille character 2x3 matrix.
I would like to have a message predefined within the code (“Hello World” seems to be a favourite) and show each character from the message on the led matrix.
I managed to do this using case statements and the serial input but after speaking to the lecturer the key is to use arrays to look up the values then fire them to the outputs. I have seen many forms of arrays on the internet for the Arduino and would firstly like to know which one is best to have all of the output pins predefined for each character.
With that array you are representing each braille character as a text sequence of zeros, ones and commas. Why not combine the ones and zeros into a single binary number that the microcontroller understands right away. Text string manipulation is costly in terms of memory use (ram is scarce on the arduino) and processing power. Instead delve into the world of bit manipulation on binary numbers through using bit-masks and bitwise-logic which is much easier for a microcontroller. So the table would contain a binary number signifying which pins/solenoids need to be activated for each (ascii) character. (or whichever symbol is also part of the braille alphabet.) Then with the proper logic rules you can digitalWrite a pin high when a certain bit in the braile-byte matches the one in the bitmask for that pin.
Hi Valen, thanks for the quick response. After a bit of reading on the links you provided(excuse the pun) it makes a lot more sense exploring the bit manipulation. I understand how I can use a byte for “a” being b0000001 as only one pin represents the letter "a " can I have a=1 which is the same as above in binary and b= 3 for two bins which would be 00000011? and then use the bit read to get get the outputs?
Ehm, looking at your earlier braille array again things are not in the exact same order. I would make a 1 dimensional table of chars (or rather unsigned 8-bit integers) that contains all braille characters. Since there are only 6 pins then this comes down to a size of 64. Since the ascii table is 4 times as large you will have to convert a subset of it (just a-z, A-Z and 0-9). So you’ll have to translate the ascii value of a desired character into an index into this byte array. This requires some if-statements, conditional logic and simple addition/subtraction to arrive at the right index value. In each element of the braille look-up table I would store a byte which 6 least significant bits have the same state as the solenoid activation. The most-significant bits of it would be 00 ofcourse. The order of those solenoid bits is arbitrary I think. It depends on how you wire it up. But I don’t know anything about braille script.