IDD Fall 2015
/
idd_fall15_hw2_inezraharjo_braille
Based on braile system for blind people.
main.cpp
- Committer:
- inezraharjo
- Date:
- 2015-09-13
- Revision:
- 5:9c64dadda024
- Parent:
- 4:4803c429f2f0
File content as of revision 5:9c64dadda024:
#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); capital = 0; 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('?', KEY_SHIFT); } if (one && !two && !three && four && !five && six){ keyboard.keyCode('!', KEY_SHIFT); } if (one && two && !three && !four && !five && !six){ keyboard.keyCode('3', KEY_SHIFT); } 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'); } */ 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); } }