What is Smart Dictionary ??
Smart Dictionary is a smarter way to know the meanings of the words that we are not so familiar of.
" Know to write(the word) ?? Then write to know(the meaning) !!"
How does Smart Dictionary work - A Theoretical Approach??
A Optical sensor along with the Contact Sensor is placed in the nib position of the pen - that takes picture of about 1000-1500 pictures/second. By acquiring sequential surface images using digital signal processing principles the direction of movement of the nib is found out using ADNS 5020 sensor package.
The output of the sensor is delivered as signals for distinct motions in the Arduino YUN Board.
The signal is used to find the coordinates of the points that the pen has moved for each letter. The coordinates of each letter is noted and uploaded using AWS Cloud in a text file.
Each letter's coordinate is stored in the Library before hand. The letter written now is compared with the library and the letter is recognized by Matrix matching(character recognition). When the Enable button is pressed(only after the letter is written) - the word is set to search.
The letters are so framed into a word and the word is searched in the dictionary in the Cloud and the meaning corresponding to the word is sent back to the Arduino YUN board and printed to the LCD display connected to the board.
Configure AWS IOT (Windows) by downloading https://s3.amazonaws.com/aws-iot-device-sdk-arduino-yun/AWS-IoT-Arduino-Yun-SDK-latest.zip. Move the AWS IOT CA file, private key and certificate into certs folder of the Arduino Yun SDK. With WinSCP upload the certs and aws_iot_mqtt_client.py file to the root directory of Yun. ssh into the yun and execute : Install pip and copy the AWS-IOT-ARDUINO-YUN-LIBRARY to the arduino libraries folder in My Documents. Restart the arduino IDE and the examples will appear in the IDE.
Transferring text file into S3 Cloud
PUT / input.txt HTTP/1.1 Host: myBucket.s3.amazonaws.com Date: Wed, 31 Jan 2016 17:50:00 GMT Authorization: authorization string Content-Type: text/plain Content-Length: 11434 x-amz-meta-author: kapil Expect: 100-continue
Arduino Code:
#include<spi.h>
#include<alphabetscode.h>
// setup pins int nReset = 12;int nCS = 13;int m,mn,m',mn';int ContactSensor= 5;int x[200,26],y[200,26]; \\x and y are the the respective coordinates of each letter stored as an array:\\Enable refers to the end of the word:\\t is the serial number of letters and i is an iterating variable:int i,t;int Enable= A0;unsigned int ADNS_read(unsigned int address);void setup(){ //set pin I/O direction pinMode (nReset, OUTPUT);pinMode (5, INPUT);pinMode (A0, INPUT);pinMode (nCS, OUTPUT); //put the device in reset not chip selected digitalWrite(nReset,LOW); digitalWrite(nCS,HIGH); //initialize SPI SPI.begin(); SPI.setDataMode(SPI_MODE3); //start a serial port for debugging Serial.begin(115200); delay(1000); Serial.println("startup complete"); } void loop(){ unsigned int read_data; delay(1000); //enable ADNS digitalWrite(nReset,HIGH); //startup time delay(1000); //read and print a register map Serial.println("ADNS-5020 Register Map"); Serial.println("Addr 0x00 - Data " + String(ADNS_read(0x00))); Serial.println("Addr 0x01 - Data " + String(ADNS_read(0x01))); Serial.println("Addr 0x02 - Data " + String(ADNS_read(0x02))); Serial.println("Addr 0x03 - Data " + String(ADNS_read(0x03))); Serial.println("Addr 0x04 - Data " + String(ADNS_read(0x04))); Serial.println("Addr 0x05 - Data " + String(ADNS_read(0x05))); Serial.println("Addr 0x06 - Data " + String(ADNS_read(0x06))); Serial.println("Addr 0x07 - Data " + String(ADNS_read(0x07))); Serial.println("Addr 0x08 - Data " + String(ADNS_read(0x08))); Serial.println("Addr 0x09 - Data " + String(ADNS_read(0x09))); Serial.println("Addr 0x0A - Data " + String(ADNS_read(0x0A))); delay(1000); } void ADNS_write(unsigned int address, unsigned int data){ // take the CS pin low to select the chip: digitalWrite(nCS,LOW); // send in the address and value via SPI: SPI.transfer(address); SPI.transfer(data); // take the SS pin high to de-select the chip: digitalWrite(nCS,HIGH); } unsigned int ADNS_read(unsigned int address) { unsigned int data; // take the CS pin low to select the chip: digitalWrite(nCS,LOW); // send in the address and value via SPI: SPI.transfer(address); pinMode(MOSI, INPUT); data = SPI.transfer(0x00); pinMode(MOSI, OUTPUT); // take the SS pin high to de-select the chip: digitalWrite(nCS,HIGH); return(data); x[0,t]=0;y[0,t]=0;t=0;\\While(Enable) to denote the end of the word and contact sensor to determint whether the pen is writing:while(Enable=0){if(ContactSensor>0){ t=t+1; if( ADNS_read(0x02) > 127)//there has been a motion! //print the x and y movements{for ( i = 0; i < 200; i++ ){x[i,t] = ADNS_read(0x03);y[i,t] = ADNS_read(0x04);}}\\After writing a letter the contact sensor is 0 till the next letter is written for text in CAPS:\\Text processing and storing the previous letter:if(ContactSensor=0){if(t>=1))m = max(x[i,t-1]);mn = min(x[i,t-1]);m' = max(y[i,t-1]);mn' = min(y[i,t-1]);x'[i,t-1] = map(x[i,t-1], mn, m, 0,10);y'[i,t-1] = map(y[i,t-1], mn', m', 0,10); \\The letters in my own header file(alphabetscode.h) that matches with the coordinates of the alphabet of the written word:\\alphabetscode.max() is to find the letters coordinates that best matches with the library:alphabetscode.max(){println("The alphabet is" aplhabetscode.max()) }\\Adding the word letter by letter to a file - input.txt:for ( i = 0; i < 200; i++ ){Serial.println(x'[i,t-1],y'[i,t-1]);Serial mySerial;PrintWriter output;\\Writing the value of arrays in a file named input:void setup() { mySerial = new Serial( this, Serial.list()[0], 9600 ); output = createWriter( "input.txt" );}void draw() { if (mySerial.available() > 0 ) { if ( x'[i,t-1]||y'[i,t-1] != null ) { output.println( x'[i,t-1],y'[i,t-1] ); } if ( x'[i,t-1]||y'[i,t-1] = null ) { output.println('\n'); \\To denote the end of the letter in the file: } }}}\\The letter is added to the file and closed:while(Enable>0)void keyPressed() { output.flush(); // Writes the remaining data to the file output.close(); // Finishes the file exit(); // Stops the program}\\When Enable is 1 the file is closed:} file is created as input.txt - containing the word.:}
--------------------------------------------------------------------------------------
\\ Code for login Amazon:
#include<bridge.h>
#include "TembooAccount.h" // contains Temboo account information, as described belowint numRuns = 1; // Execution count, so this doesn't run foreverint maxRuns = 10; // Maximum number of times the Choreo should be executedvoid setup() { Serial.begin(9600); // For debugging, wait until the serial console is connected delay(4000); while(!Serial); Bridge.begin();}void loop() { if (numRuns <= maxRuns) { Serial.println("Running InitializeOAuth - Run #" + String(numRuns++)); TembooChoreo InitializeOAuthChoreo; // Invoke the Temboo client InitializeOAuthChoreo.begin(); // Set Temboo account credentials InitializeOAuthChoreo.setAccountName(TEMBOO_ACCOUNT); InitializeOAuthChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); InitializeOAuthChoreo.setAppKey(TEMBOO_APP_KEY); // Set Choreo inputs InitializeOAuthChoreo.addInput("Scope", "cloudsearch:read"); InitializeOAuthChoreo.addInput("ClientID", "AKIAJRHE5BHLXBABUNMA"); // Identify the Choreo to run InitializeOAuthChoreo.setChoreo("/Library/Amazon/LoginWithAmazon/InitializeOAuth"); // Run the Choreo; when results are available, print them to serial InitializeOAuthChoreo.run(); while(InitializeOAuthChoreo.available()) { char c = InitializeOAuthChoreo.read(); Serial.print(c); } InitializeOAuthChoreo.close(); } Serial.println("Waiting..."); delay(30000); // wait 30 seconds between InitializeOAuth calls}
---------------------------------------------------------------------------------------
Comments