Universal Translator
Universal Translator
The universal translator allows the user to select the language which he intends to input, type a statement, select a language for translation, and hear how his statement is pronounced in the selected language.
mbed Peripherals
- PS2 Connector and PS2 Keyboard
- Inputs a message and selects information
- LCD Display
- Displays the current message
- Ethernet Connection
- Passes the inputted statement to Google Translator and Google Text-To-Speech
- Serial PC Connection
- Displays the IP address of the Ethernet along with any Ethernet error information
- SD Card
- Stores the .mp3 file returned from Google Text-To-Speech
- VS1053
- Converts the .mp3 file into an audio signal
- Audio Out and Speaker
- Plays the .mp3 file
- Potentiometer
- Adjusts speaker volume
User Instructions
1. Wait for the first LED to start blinking. Once this occurs, the mbed has connected through the Ethernet and is prepared for inputs.
2. Type in the message that you wish to translate. Below are a list of keys available.
Keys Available for Input Text All letters
- All numbers
- Space bar
- Comma
- Period
- Forward slash
- Back slash
- Semicolon
- Dash
- Opening and closing brackets
- Equals sign
Other Input Keys
- Backspace
- Deletes the previous character in the message
- Delete
- Clears the entire message
- Up arrow
- Scrolls up 1 line on the LCD display of the message
- Down arrow
- Scrolls down 1 line on the LCD display of the message
- Right arrow
- Scrolls 1 letter to the right on the LCD display of the message
- Left arrow
- Scrolls 1 letter to the left on the LCD display of the message
- Enter
- Submits the message for translation
Note!
When scrolling through the message and making changes, the program will write over old characters, as the insert button functions on a computer.
3. Once the message has been entered, press enter.
4. A screen will appear with a first line stating "SELECT SRC LANG." This screen requests that select the language of the input message, the source language. The second line of this screen will be a language.
5. Use the up and down arrow keys to change the source language.
6. When the correct source language is on the screen, press enter to select it.
7. A screen will appear with a first line stating "SELECT DEST LANG." This screen requests that the language for the message to be translated into, the destination language, be selected. The second line of the screen will be a language.
8. Use the up and down arrow keys to change the destination language.
9. When the correct destination language is on the screen, press enter.
10. The message will be translated and played through the speaker.
Demo Video
Download the Program
Import programLab3Translator
Universal Translator
Important!
Once the code is downloaded, you must open keyProcess.cpp, proceed to line 31, and insert your website. You must have a website for the program to write the message for Google Translator to translate. Line 31 currently reads:
static string httptransurl = "http://www.yoursite.com/path/to/mbed.php?src="; INSERT YOUR WEBSITE HERE!
The code WILL NOT function before this task is completed.
You can find information about setting up your Google API key here: https://www.google.com/accounts/ServiceLogin?service=devconsole&passive=1209600&continue=https://code.google.com/apis/console/?api%3Dtranslate&followup=https://code.google.com/apis/console/?api%3Dtranslate
Currently, there is a working URL that is available for use (as long as it is not abused): http://www.starboundcomputers.com/mbed.php?src= (this goes in the httptransurl variable).
Lines 23-39 of keyProcess.cpp
keyProcess.cpp
void checkKeys(PS2Keyboard &ps2kb,char* rowstr) { static int column = 0; static int row = 0; static int selected = true; static int source = false; static const char *selsrc="Select Src Lang\n"; static const char *seldest="Select Dest Lang"; static string httpurl = "http://translate.google.com/translate_tts?tl="; static string httptransurl = "http://www.yoursite.com/path/to/mbed.php?src=";//INSERT YOUR WEBSITE HERE! static string arg = "&q="; string voiceurl; string transurl; static int src=26; static int dest=37; string lang; string translatedText; static PS2Keyboard::keyboard_event_t evt_kb;
mbed.php
<?php $key = " "; /* insert your key */ $q = urlencode($_GET["q"]); $src = $_GET["src"]; $dest = $_GET["dest"]; $url = "https://www.googleapis.com/language/translate/v2?key=".$key."&q=".$q."&source=".$src."&target=".$dest; // sendRequest // note how referer is set manually $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, "http://www.yoursite.com/path/to/mbed.php?src=");/* Enter the URL of your site here */ $body = curl_exec($ch); curl_close($ch); // now, process the JSON string $json = json_decode($body,true); $translatedText = $json["data"]["translations"][0]["translatedText"]; echo $translatedText; ?>
Serial Communication with PC
For Ethernet debugging purposes, there is a serial display on the PC.
Information on configuring serial on Windows is found here: http://mbed.org/handbook/Windows-serial-configuration
LCD Screen
Pin Out
Mbed Pins | TextLCD Pins |
---|---|
GND | GND |
5V | VCC |
GND (via 1k resistor) | V0 |
P15 | RS |
GND | RW |
P16 | E |
N/C | D0 |
N/C | D1 |
N/C | D2 |
N/C | D3 |
P17 | D4 |
P18 | D5 |
P19 | D6 |
P20 | D7 |
More information about the LCD Display may be found here: http://mbed.org/cookbook/Text-LCD
PS2 Keyboard
Pin Out
Mbed Pins | PS2 Connector Pins | Value of Resistor the Connection is made through |
5V | DATA | 4.7K |
P29 | DATA | 270 |
P30 | DATA | 270 |
GND | GND | Wire |
5V | VCC | Wire |
P29 | CLK | 270 |
P30 | CLK | 270 |
5V | CLK | 4.7K |
PS2KeyMap
static const unsigned char ps2KeyMap[] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', '`','\0', // 00-0F '\0','\0','\0','\0','\0', 'Q', '1','\0','\0','\0', 'Z', 'S', 'A', 'W', '2','\0', // 10-1F '\0', 'C', 'X', 'D', 'E', '4', '3','\0','\0',' ', 'V', 'F', 'T', 'R', '5','\0', // 20-2F '\0', 'N', 'B', 'H', 'G', 'Y', '6','\0','\0', '\0', 'M', 'J', 'U', '7', '8','\0', // 30-3F '\0', ',', 'K', 'I', 'O', '0', '9','\0','\0', '.', '/', 'L', ';', 'P', '-','\0', // 40-4F '\0','\0', '\'','\0', '[', '=','\0','\0','\0','\0','\0', ']','\0','\\','\0','\0', // 50-5F '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 60-6F '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 70-7F '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 80-8F '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 90-9F '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // A0-AF '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // B0-BF '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // C0-CF '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // D0-DF '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // E0-EF '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // F0-FF };
Information about the PS2 connector can be found here: http://mbed.org/cookbook/PS2
Information about the code mouse and keyboard PS2 devices can be found here: http://mbed.org/users/shintamainjp/libraries/PS2/lg73er
VS1053
Pin Out
Mbed Pins | VS1053 Pins |
---|---|
VOUT | VCC |
N/C | MICN |
P21 | RESET |
P22 | DREQ |
N/C | GPIO0 |
N/C | GPIO1 |
N/C | GPIO2 |
N/C | GPIO3 |
P23 | BSYNC |
N/C | TX |
N/C | RX |
GND | GND |
P11 | SI |
P12 | SO |
P13 | SCLK |
P10 | CS |
GND | GBUF |
VCC | LEFT |
VS1053 Datasheet: http://www.vlsi.fi/fileadmin/datasheets/vlsi/vs1053.pdf
A VS1002 MP3 Decoder may be used in place of the VS1053. Software origonally designed for the VS1002 was used in the project.
Information on the VS1002 MP3 Decoder and the corresponding software may be found here: http://mbed.org/cookbook/VS1002-MP3-Decoder
Audio Out
Pin Out
VS1052 Pins | Breakout Board Pins |
---|---|
GND | GND |
RIGHT | RSH |
LEFT | TSH |
Information on the breakout board can be found here: http://www.sparkfun.com/products/8827
Volume Controlling Potentiometer
Pin Out
Mbed Pins | Potentiometer Pins |
---|---|
VOUT | VCC |
GND | GND |
P15 | Volume Control |
SD Card
Pin Out
Mbed Pins | SD Card Breakout Board Pins |
---|---|
P8 | CS |
P5 | DI |
VOUT | VCC |
P7 | SCK |
GND | GND |
P6 | DO |
N/C | CD |
Information on the SparkFun MicroSD Breakout Board can be found here: http://www.sparkfun.com/products/544
Information on SD Card interface with the mbed can be found here: http://mbed.org/cookbook/SD-Card-File-System
Ethernet
Pin Out
Mbed Pins | Ethernet Pins |
---|---|
TD+ | P1 |
TD- | P2 |
RD+ | P7 |
RD- | P8 |
Information on Ethernet may be found here: http://mbed.org/cookbook/Ethernet
Information on the RJ45 MagJack Ethernet Breakout Board may be found here: http://mbed.org/cookbook/Ethernet-RJ45
Please log in to post comments.