Braille Tweeter: Difference between revisions

From Nottinghack Wiki
Jump to navigation Jump to search
Dex (talk | contribs)
No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Project
|image=
|name=Braille Tweeter
|primary=[[User:Russell|Russell]]
|created=04/06/2011
|completeddate=
|dormantdate=
|version=
|members=
|status=Complete
|type=member
|livestatus=
|qrmode=1
}}
[[Image:The-braille-tweeter-on-open-day-2011.jpg|thumb|none|450px]]
[[Image:The-braille-tweeter-on-open-day-2011.jpg|thumb|none|450px]]


This is a project to turn a cheap braille note taker, that prints on ticker tape, into a braille tweet printer.
This is a project to turn a cheap braille note taker, that prints on ticker tape, into a braille tweet printer.


This has it's own blog page at
This has it's own blog page at:


http://russelljenkinsfearn.blogspot.com/
http://russelljenkinsfearn.blogspot.com/
==Arduino Code==
This code was taken from Russell's Blog on 06/02/2019:
<pre>
/*
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);
}
</pre>


[[Category:Projects]]
[[Category:Projects]]
[[Category:Projects (completed)]]
[[Category:Projects (complete)]]

Latest revision as of 13:32, 6 February 2019

Braille Tweeter
[[|border|frameless|220px|center]]
Primary Contact Russell
Created 04/06/2011
Completed
Dormant
Version
Members
Manufacturer {{{manufacturer}}}
Model {{{model}}}
Location [[{{{location}}}]]
GitHub / Repo {{{repo}}}
Status Complete
Type Members Project
Live Status
QR code

This is a project to turn a cheap braille note taker, that prints on ticker tape, into a braille tweet printer.

This has it's own blog page at:

http://russelljenkinsfearn.blogspot.com/

Arduino Code

This code was taken from Russell's Blog on 06/02/2019:


/*
 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); 
}