Based on braile system for blind people.

Dependencies:   USBDevice mbed

main.cpp

Committer:
inezraharjo
Date:
2015-09-13
Revision:
4:4803c429f2f0
Parent:
3:e61ba28a98aa
Child:
5:9c64dadda024

File content as of revision 4:4803c429f2f0:

#include "mbed.h"
#include <math.h>
#include "USBKeyboard.h"
 
//USBKeyboard
USBKeyboard keyboard;
 
//DigitalOut myled(LED1);
//DigitalOut led2(LED2);
//DigitalOut led3(LED3);
DigitalIn pb(D2);
DigitalIn pb2(D4);
DigitalIn pb3(D8);
DigitalIn pb4(D11);
DigitalIn pb5(D14);
DigitalIn pb6(D15);
int one, two, three, four, five, six, capital;
// SPST Pushbutton demo using internal PullUp function
// no external PullUp resistor needed
// Pushbutton from P8 to GND.
int main() {
    pb.mode(PullUp);
    pb2.mode(PullUp);
    pb3.mode(PullUp);
    pb4.mode(PullUp);
    pb5.mode(PullUp);
    pb6.mode(PullUp);
    while(1) {
        while (pb && pb2 && pb3 && pb4 && pb5 && pb6){
            if (!one && two && three && four && five && six){
                keyboard.keyCode('a');
            } 
            if (!one && !two && three && four && five && six){
                keyboard.keyCode('b');
            } 
            if (!one && two && three && four && five && !six) {
                keyboard.keyCode('c');
            }
            if (!one && two && three && four && !five && !six){
                keyboard.keyCode('d');
            }
            if (!one && two && three && four && !five && six){
                keyboard.keyCode('e');
            }
            if (!one && !two && three && four && five && !six){
                keyboard.keyCode('f');
            }
            if (!one && !two && three && four && !five && !six){
                keyboard.keyCode('g');
            }
            if (!one && !two && three && four && !five && six){
                keyboard.keyCode('h');
            }
            if (one && !two && three && four && five && !six){
                keyboard.keyCode('i');
            }
            if (one && !two && three && four && !five && !six){
                keyboard.keyCode('j');
            }
            if (!one && two && !three && four && five && six){
                keyboard.keyCode('k');
            }
            if (!one && !two && !three && four && five && six){
                keyboard.keyCode('l');
            }
            if (!one && two && !three && four && five && !six){
                keyboard.keyCode('m');
            }
            if (!one && two && !three && four && !five && !six){
                keyboard.keyCode('n');
            }
            if (!one && two && !three && four && !five && six){
                keyboard.keyCode('o');
            }
            if (!one && !two && !three && four && five && !six){
                keyboard.keyCode('p');
            }
            if (!one && !two && !three && four && !five && !six){
                keyboard.keyCode('q');
            }
            if (!one && !two && !three && four && !five && six){
                keyboard.keyCode('r');
            }
            if (one && !two && !three && four && five && !six){
                keyboard.keyCode('s');
            }
            if (one && !two && !three && four && !five && !six){
                keyboard.keyCode('t');
            }
            if (!one && two && !three && !four && five && six){
                keyboard.keyCode('u');
            }
            if (!one && !two && !three && !four && five && six){
                keyboard.keyCode('v');
            }
            if (one && !two && three && !four && !five && !six){
                keyboard.keyCode('w');
            }
            if (!one && two && !three && !four && five && !six){
                keyboard.keyCode('x');
            }
            if (!one && two && !three && !four && !five && !six){
                keyboard.keyCode('y');
            }
            if (!one && two && !three && !four && !five && six){
                keyboard.keyCode('z');
            }
            if (one && two && !three && !four && five && six){
                keyboard.keyCode(' ');
            }
            if (one && !two && !three && !four && five && six){
                keyboard.keyCode('?');
            }
            if (one && !two && !three && four && !five && six){
                keyboard.keyCode('!');
            }
            if (one && two && !three && four && five && six){
                keyboard.keyCode('\'');
            }
            if (one && !two && three && four && five && six){
                keyboard.keyCode(',');
            }
            if (one && !two && three && !four && !five && six){
                keyboard.keyCode('.');
            }
            if (one && two && !three && !four && !five && !six){
                keyboard.keyCode('#');
            }
           /* if (one && !two && three && four && !five && !six){
                keyboard.keyCode('0');
            }
            if (!one && two && three && four && five && six){
                keyboard.keyCode('1');
            }
            if (!one && !two && three && four && five && six){
                keyboard.keyCode('2');
            }
            if (!one && two && three && four && five && !six){
                keyboard.keyCode('3');
            }
            if (!one && two && three && four && !five && !six){
                keyboard.keyCode('4');
            }
            if (!one && two && three && four && !five && six){
                keyboard.keyCode('5');
            }
            if (!one && !two && three && four && five && !six){
                keyboard.keyCode('6');
            }
            if (!one && !two && three && four && !five && !six){
                keyboard.keyCode('7');
            }
            if (!one && !two && three && four && !five && six){
                keyboard.keyCode('8');
            }
            if (one && !two && three && four && five && !six){
                keyboard.keyCode('9');
            } */
            if (one && two && three && four && five && six){
                capital = 1;
            }
            if (capital){
                capital = 0;
                if (!one && two && three && four && five && six){
                    keyboard.keyCode('A');
                } 
                if (!one && !two && three && four && five && six){
                    keyboard.keyCode('B');
                } 
                if (!one && two && three && four && five && !six) {
                    keyboard.keyCode('C');
                }
                if (!one && two && three && four && !five && !six){
                    keyboard.keyCode('D');
                }
                if (!one && two && three && four && !five && six){
                    keyboard.keyCode('E');
                }
                if (!one && !two && three && four && five && !six){
                    keyboard.keyCode('F');
                }
                if (!one && !two && three && four && !five && !six){
                    keyboard.keyCode('G');
                }
                if (!one && !two && three && four && !five && six){
                    keyboard.keyCode('H');
                }
                if (one && !two && three && four && five && !six){
                    keyboard.keyCode('I');
                }
                if (one && !two && three && four && !five && !six){
                    keyboard.keyCode('J');
                }
                if (!one && two && !three && four && five && six){
                    keyboard.keyCode('K');
                }
                if (!one && !two && !three && four && five && six){
                    keyboard.keyCode('L');
                }
                if (!one && two && !three && four && five && !six){
                    keyboard.keyCode('M');
                }
                if (!one && two && !three && four && !five && !six){
                    keyboard.keyCode('N');
                }
                if (!one && two && !three && four && !five && six){
                    keyboard.keyCode('O');
                }
                if (!one && !two && !three && four && five && !six){
                    keyboard.keyCode('P');
                }
                if (!one && !two && !three && four && !five && !six){
                    keyboard.keyCode('Q');
                }
                if (!one && !two && !three && four && !five && six){
                    keyboard.keyCode('R');
                }
                if (one && !two && !three && four && five && !six){
                    keyboard.keyCode('S');
                }
                if (one && !two && !three && four && !five && !six){
                    keyboard.keyCode('T');
                }
                if (!one && two && !three && !four && five && six){
                    keyboard.keyCode('U');
                }
                if (!one && !two && !three && !four && five && six){
                    keyboard.keyCode('V');
                }
                if (one && !two && three && !four && !five && !six){
                    keyboard.keyCode('W');
                }
                if (!one && two && !three && !four && five && !six){
                    keyboard.keyCode('X');
                }
                if (!one && two && !three && !four && !five && !six){
                    keyboard.keyCode('Y');
                }
                if (!one && two && !three && !four && !five && six){
                    keyboard.keyCode('Z');
                }
            }
            one = 1;
            two = 1;
            three = 1;
            four = 1;
            five = 1;
            six = 1;
        }
        wait(0.1);
        
        while (!pb || !pb2 || !pb3 || !pb4 || !pb5 || !pb6){
            if (!pb){
                one=0;
            } 
            if (!pb2){
                two=0;
            } 
            if (!pb3){
                three=0;
            } 
            if (!pb4){
                four=0;
            } 
            if (!pb5){
                five=0;
            } 
            if (!pb6){
                six=0;
            }

        }

        wait(0.1);
               
    }
}