SO I have attached the solenoids to the base of the printer and finally hooked everything up.
It even kind of works and you can see in this video.
I guess there is now a whole lot of adjusting to do until it works properly and reliably
Braille Tweeter
Monday, 17 October 2011
Tuesday, 24 May 2011
Braille LEDs
So I'm not showing this is the right order but before I connected the solenoids I debugged the Arduino code using a test rig of LEDs. I set up the LEDs on a breadboard in a braille cell configuration to test that the arduino code was setting and resetting the digi pins correctly. Good job I did because it was a bloody mess. I did finally get the code right though. Here is a blurry picture or three of the LED rig
and a short video of it displaying some visual braille.
and a short video of it displaying some visual braille.
Sunday, 15 May 2011
Arduino Code
Here's the code I am runnning on the arduino. It may change a little bit, for timing reasons for example, but not much I think.
/*
Receives ascii bytes across the serial and
displays them as braille characters.
If it is a digit or string of digits
it displays the 'Number' symbols first.
If it is a space it operates a seperate 'Space Bar' digi pin.
If it starts with a capital letter it inserts a Captial symbol first.
It also send lots of stuff back, just for debugging really.
*/
int bitCount; // Just counts throught the braille dots
int PosInAlpha = 0; // Where in the 'alphabet' below to find the brailled representation
int brailled = 0; // We store the curenr representation here
char inChar ; // Incoming serial byte
int inByte; // The Ascii version of current character
int numFlag = 0; // was it a number?
int moreNums = 0; // was the last one a number too?
int cptFlag = 0; // was it a capital letter?
int moreCpt = 0; // was the last one a capital(or other letter) too?
int deelay = 400; // this is the delay between characters, so we can speed it up later
int alphabet[] =
{
0,32,48,36,38,34,52,54,50,20,22,40,56,44,46,42,60,62,58,28,30,41,57,23,45,47,43,26, 8,27,16, 9,19,18,24,25};
// a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, ! ' () , - . : ; ?
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT); // Dot 1
pinMode(3, OUTPUT); // Dot 2
pinMode(4, OUTPUT); // Dot 3
pinMode(5, OUTPUT); // Dot 4
pinMode(6, OUTPUT); // Dot 5
pinMode(7, OUTPUT); // Dot 6
pinMode(8, OUTPUT); // Space Bar
Serial.println(" ");
}
void loop()
{
int numSymbol = 15; //that's the number symbol
int capSymbol = 1; //that's the CAPITALS symbol
//Is there anything comming in?
if (Serial.available() > 0)
{
// get the incoming byte:
inChar = Serial.read();
PosInAlpha = 255; // a default number to check leter to see if we found a transliteration
inByte = int(inChar); // get the ascii code for it
Serial.print("Ascii "); // print it for debugging.
Serial.println(inByte); // print it for debugging.
if ((inByte >= 48) and (inByte <= 57)) // If it is a number
{
Serial.println("So it's a number");
cptFlag = 0; // Reset both Capital flgs
moreCpt = 0;
if (numFlag == 1) // If the number flag is already set , then set the 'middle of a number' flag
{
moreNums = 1;
}
numFlag = 1; // Set the flag to add in the number symbol
PosInAlpha = inByte - 48; // map 1,2,3 onto a,b,c
if (PosInAlpha == 0) // Map zero onto 'j'
{
PosInAlpha=10;
}
}
else // It isn't a number
{
numFlag = 0; // reset both flags
moreNums = 0;
if ((inByte >= 65) and (inByte <= 90)) // Uppercase letters
{
PosInAlpha = inByte - 64;
if (cptFlag == 1)
{
moreCpt = 1;
}
cptFlag = 1;
}
if ((inByte >= 97) and (inByte <= 122)) // lowercase letters
{
PosInAlpha = inByte - 96;
moreCpt = 1;
}
switch (inByte) // remember these arn't brailled digits, just pointers to where in the 'Alphabet' at the top to find the binary
{
case 32: // Space character. Something else will have to happen here eventually
PosInAlpha = 0;
cptFlag = 0;
moreCpt = 0;
break;
case 33: // Exclamation mark
PosInAlpha = 27;
cptFlag = 0;
moreCpt = 0;
Serial.println("exclamation mark");
break;
case 39:
PosInAlpha = 28; // apostrophe, Note it can be found in the middle of a word so don't reset the Capital flags
Serial.println("apostrophe");
break;
case 40: // Open Bracket
PosInAlpha = 29;
cptFlag = 0;
moreCpt = 0;
Serial.println("Open Bracket");
break;
case 41: // Close bracket. Yes it's the same as open
PosInAlpha = 29;
cptFlag = 0;
moreCpt = 0;
Serial.println("Close bracket");
break;
case 44: // comma
PosInAlpha = 30;
cptFlag = 0;
moreCpt = 0;
Serial.println("comma");
break;
case 45: // dash. Note it can be found in the middle of a word so don't reset the Capital flags
PosInAlpha = 31;
Serial.println(" dash");
break;
case 46: // Full stop
PosInAlpha = 32;
cptFlag = 0;
moreCpt = 0;
Serial.println("full stop");
break;
case 58: // colon
PosInAlpha = 33;
cptFlag = 0;
moreCpt = 0;
Serial.println("colon");
break;
case 59: // semi colon
PosInAlpha = 34;
cptFlag = 0;
moreCpt = 0;
Serial.println("semi colon");
break;
case 63: // question mark
PosInAlpha = 35;
cptFlag = 0;
moreCpt = 0;
Serial.println("question mark");
break;
}
}
brailled = alphabet[PosInAlpha]; //get the binary representation of the braille dots
Serial.print(" brailled ");
Serial.println(brailled);
if (brailled != 255) // i.e. if we found any valid transliteration
{
if ((numFlag == 1) and (moreNums == 0)) // if it's a number and the last one wasn't
// we add in a 'number' symbol just before the digits
{
printOne(numSymbol);
Serial.println("Number sign");
delay(deelay);
printOne(0);
}
if ((cptFlag == 1) and (moreCpt == 0)) // if it's a capital and it's the first letter in the word
// we add in a 'Captials' symbol here just before it
{
printOne(capSymbol);
Serial.println("Capital");
delay(deelay);
printOne(0);
}
// Now we print the character for real
if (inByte == 32) // If it's a space push the space bar!
{
Serial.print("Space ");
digitalWrite(8, HIGH);
}
Serial.print(inChar); // for debugging
Serial.print(" ");
printOne(brailled);
Serial.println("");
printOne(0); // Now reset all the digi pins before the next character.
digitalWrite(8, LOW);
delay(deelay);
}
}
else
{
numFlag = 0; // Reset all the flags before we start again.
moreNums = 0;
cptFlag = 0;
moreCpt = 0;
}
}
void printOne(int chr)
{
for (int bitCount=6; bitCount>0; bitCount--) //go through the six dots setting them correctly
// Watch out! It goes throught them in reverse, 6,5,4,3,2,1
{
if ( chr % 2 == 0 )
{
Serial.print("0");
digitalWrite(bitCount+1, LOW); // We are setting digi pin + 1 because we couldn't use pin 1 'cos it's wierd
}
else
{
Serial.print("1");
digitalWrite(bitCount+1, HIGH);
}
chr = chr / 2;
}
Serial.println("");
delay(deelay);
}
/*
Receives ascii bytes across the serial and
displays them as braille characters.
If it is a digit or string of digits
it displays the 'Number' symbols first.
If it is a space it operates a seperate 'Space Bar' digi pin.
If it starts with a capital letter it inserts a Captial symbol first.
It also send lots of stuff back, just for debugging really.
*/
int bitCount; // Just counts throught the braille dots
int PosInAlpha = 0; // Where in the 'alphabet' below to find the brailled representation
int brailled = 0; // We store the curenr representation here
char inChar ; // Incoming serial byte
int inByte; // The Ascii version of current character
int numFlag = 0; // was it a number?
int moreNums = 0; // was the last one a number too?
int cptFlag = 0; // was it a capital letter?
int moreCpt = 0; // was the last one a capital(or other letter) too?
int deelay = 400; // this is the delay between characters, so we can speed it up later
int alphabet[] =
{
0,32,48,36,38,34,52,54,50,20,22,40,56,44,46,42,60,62,58,28,30,41,57,23,45,47,43,26, 8,27,16, 9,19,18,24,25};
// a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, ! ' () , - . : ; ?
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT); // Dot 1
pinMode(3, OUTPUT); // Dot 2
pinMode(4, OUTPUT); // Dot 3
pinMode(5, OUTPUT); // Dot 4
pinMode(6, OUTPUT); // Dot 5
pinMode(7, OUTPUT); // Dot 6
pinMode(8, OUTPUT); // Space Bar
Serial.println(" ");
}
void loop()
{
int numSymbol = 15; //that's the number symbol
int capSymbol = 1; //that's the CAPITALS symbol
//Is there anything comming in?
if (Serial.available() > 0)
{
// get the incoming byte:
inChar = Serial.read();
PosInAlpha = 255; // a default number to check leter to see if we found a transliteration
inByte = int(inChar); // get the ascii code for it
Serial.print("Ascii "); // print it for debugging.
Serial.println(inByte); // print it for debugging.
if ((inByte >= 48) and (inByte <= 57)) // If it is a number
{
Serial.println("So it's a number");
cptFlag = 0; // Reset both Capital flgs
moreCpt = 0;
if (numFlag == 1) // If the number flag is already set , then set the 'middle of a number' flag
{
moreNums = 1;
}
numFlag = 1; // Set the flag to add in the number symbol
PosInAlpha = inByte - 48; // map 1,2,3 onto a,b,c
if (PosInAlpha == 0) // Map zero onto 'j'
{
PosInAlpha=10;
}
}
else // It isn't a number
{
numFlag = 0; // reset both flags
moreNums = 0;
if ((inByte >= 65) and (inByte <= 90)) // Uppercase letters
{
PosInAlpha = inByte - 64;
if (cptFlag == 1)
{
moreCpt = 1;
}
cptFlag = 1;
}
if ((inByte >= 97) and (inByte <= 122)) // lowercase letters
{
PosInAlpha = inByte - 96;
moreCpt = 1;
}
switch (inByte) // remember these arn't brailled digits, just pointers to where in the 'Alphabet' at the top to find the binary
{
case 32: // Space character. Something else will have to happen here eventually
PosInAlpha = 0;
cptFlag = 0;
moreCpt = 0;
break;
case 33: // Exclamation mark
PosInAlpha = 27;
cptFlag = 0;
moreCpt = 0;
Serial.println("exclamation mark");
break;
case 39:
PosInAlpha = 28; // apostrophe, Note it can be found in the middle of a word so don't reset the Capital flags
Serial.println("apostrophe");
break;
case 40: // Open Bracket
PosInAlpha = 29;
cptFlag = 0;
moreCpt = 0;
Serial.println("Open Bracket");
break;
case 41: // Close bracket. Yes it's the same as open
PosInAlpha = 29;
cptFlag = 0;
moreCpt = 0;
Serial.println("Close bracket");
break;
case 44: // comma
PosInAlpha = 30;
cptFlag = 0;
moreCpt = 0;
Serial.println("comma");
break;
case 45: // dash. Note it can be found in the middle of a word so don't reset the Capital flags
PosInAlpha = 31;
Serial.println(" dash");
break;
case 46: // Full stop
PosInAlpha = 32;
cptFlag = 0;
moreCpt = 0;
Serial.println("full stop");
break;
case 58: // colon
PosInAlpha = 33;
cptFlag = 0;
moreCpt = 0;
Serial.println("colon");
break;
case 59: // semi colon
PosInAlpha = 34;
cptFlag = 0;
moreCpt = 0;
Serial.println("semi colon");
break;
case 63: // question mark
PosInAlpha = 35;
cptFlag = 0;
moreCpt = 0;
Serial.println("question mark");
break;
}
}
brailled = alphabet[PosInAlpha]; //get the binary representation of the braille dots
Serial.print(" brailled ");
Serial.println(brailled);
if (brailled != 255) // i.e. if we found any valid transliteration
{
if ((numFlag == 1) and (moreNums == 0)) // if it's a number and the last one wasn't
// we add in a 'number' symbol just before the digits
{
printOne(numSymbol);
Serial.println("Number sign");
delay(deelay);
printOne(0);
}
if ((cptFlag == 1) and (moreCpt == 0)) // if it's a capital and it's the first letter in the word
// we add in a 'Captials' symbol here just before it
{
printOne(capSymbol);
Serial.println("Capital");
delay(deelay);
printOne(0);
}
// Now we print the character for real
if (inByte == 32) // If it's a space push the space bar!
{
Serial.print("Space ");
digitalWrite(8, HIGH);
}
Serial.print(inChar); // for debugging
Serial.print(" ");
printOne(brailled);
Serial.println("");
printOne(0); // Now reset all the digi pins before the next character.
digitalWrite(8, LOW);
delay(deelay);
}
}
else
{
numFlag = 0; // Reset all the flags before we start again.
moreNums = 0;
cptFlag = 0;
moreCpt = 0;
}
}
void printOne(int chr)
{
for (int bitCount=6; bitCount>0; bitCount--) //go through the six dots setting them correctly
// Watch out! It goes throught them in reverse, 6,5,4,3,2,1
{
if ( chr % 2 == 0 )
{
Serial.print("0");
digitalWrite(bitCount+1, LOW); // We are setting digi pin + 1 because we couldn't use pin 1 'cos it's wierd
}
else
{
Serial.print("1");
digitalWrite(bitCount+1, HIGH);
}
chr = chr / 2;
}
Serial.println("");
delay(deelay);
}
Solenoids in action
I got most of the solenoids working today. I suspended them from a wooden pole to watch them pulling up as the arduino sends the braille dots. Here's a short video of them in action.
Next I need to do all the mechanical work to attach them to the printer keys and hide the arduino and circuit board in the printer base.
Next I need to do all the mechanical work to attach them to the printer keys and hide the arduino and circuit board in the printer base.
Tuesday, 3 May 2011
Braille twitter
Subscribe to:
Posts (Atom)