IDD Fall 2015
/
idd_fall15_hw2_inezraharjo_braille
Based on braile system for blind people.
main.cpp@0:c31de740c873, 2015-09-13 (annotated)
- Committer:
- inezraharjo
- Date:
- Sun Sep 13 00:04:17 2015 +0000
- Revision:
- 0:c31de740c873
- Child:
- 1:7c1f8a60c3d4
Braile Text Entry Input v1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inezraharjo | 0:c31de740c873 | 1 | #include "mbed.h" |
inezraharjo | 0:c31de740c873 | 2 | #include <math.h> |
inezraharjo | 0:c31de740c873 | 3 | #include "USBKeyboard.h" |
inezraharjo | 0:c31de740c873 | 4 | |
inezraharjo | 0:c31de740c873 | 5 | //USBKeyboard |
inezraharjo | 0:c31de740c873 | 6 | USBKeyboard keyboard; |
inezraharjo | 0:c31de740c873 | 7 | |
inezraharjo | 0:c31de740c873 | 8 | //DigitalOut myled(LED1); |
inezraharjo | 0:c31de740c873 | 9 | //DigitalOut led2(LED2); |
inezraharjo | 0:c31de740c873 | 10 | //DigitalOut led3(LED3); |
inezraharjo | 0:c31de740c873 | 11 | DigitalIn pb(D2); |
inezraharjo | 0:c31de740c873 | 12 | DigitalIn pb2(D4); |
inezraharjo | 0:c31de740c873 | 13 | DigitalIn pb3(D8); |
inezraharjo | 0:c31de740c873 | 14 | DigitalIn pb4(D11); |
inezraharjo | 0:c31de740c873 | 15 | DigitalIn pb5(D14); |
inezraharjo | 0:c31de740c873 | 16 | DigitalIn pb6(D15); |
inezraharjo | 0:c31de740c873 | 17 | int one, two, three, four, five, six; |
inezraharjo | 0:c31de740c873 | 18 | // SPST Pushbutton demo using internal PullUp function |
inezraharjo | 0:c31de740c873 | 19 | // no external PullUp resistor needed |
inezraharjo | 0:c31de740c873 | 20 | // Pushbutton from P8 to GND. |
inezraharjo | 0:c31de740c873 | 21 | int main() { |
inezraharjo | 0:c31de740c873 | 22 | pb.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 23 | pb2.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 24 | pb3.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 25 | pb4.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 26 | pb5.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 27 | pb6.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 28 | while(1) { |
inezraharjo | 0:c31de740c873 | 29 | while (pb && pb2 && pb3 && pb4 && pb5 && pb6){ |
inezraharjo | 0:c31de740c873 | 30 | if (!one && two && three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 31 | keyboard.keyCode('a'); |
inezraharjo | 0:c31de740c873 | 32 | } |
inezraharjo | 0:c31de740c873 | 33 | if (!one && !two && three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 34 | keyboard.keyCode('b'); |
inezraharjo | 0:c31de740c873 | 35 | } |
inezraharjo | 0:c31de740c873 | 36 | if (!one && two && three && four && five && !six) { |
inezraharjo | 0:c31de740c873 | 37 | keyboard.keyCode('c'); |
inezraharjo | 0:c31de740c873 | 38 | } |
inezraharjo | 0:c31de740c873 | 39 | if (!one && two && three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 40 | keyboard.keyCode('d'); |
inezraharjo | 0:c31de740c873 | 41 | } |
inezraharjo | 0:c31de740c873 | 42 | if (!one && two && three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 43 | keyboard.keyCode('e'); |
inezraharjo | 0:c31de740c873 | 44 | } |
inezraharjo | 0:c31de740c873 | 45 | if (!one && !two && three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 46 | keyboard.keyCode('f'); |
inezraharjo | 0:c31de740c873 | 47 | } |
inezraharjo | 0:c31de740c873 | 48 | if (!one && !two && three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 49 | keyboard.keyCode('g'); |
inezraharjo | 0:c31de740c873 | 50 | } |
inezraharjo | 0:c31de740c873 | 51 | if (!one && !two && three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 52 | keyboard.keyCode('h'); |
inezraharjo | 0:c31de740c873 | 53 | } |
inezraharjo | 0:c31de740c873 | 54 | if (one && !two && three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 55 | keyboard.keyCode('i'); |
inezraharjo | 0:c31de740c873 | 56 | } |
inezraharjo | 0:c31de740c873 | 57 | if (one && !two && three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 58 | keyboard.keyCode('j'); |
inezraharjo | 0:c31de740c873 | 59 | } |
inezraharjo | 0:c31de740c873 | 60 | if (!one && two && !three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 61 | keyboard.keyCode('k'); |
inezraharjo | 0:c31de740c873 | 62 | } |
inezraharjo | 0:c31de740c873 | 63 | if (!one && !two && !three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 64 | keyboard.keyCode('l'); |
inezraharjo | 0:c31de740c873 | 65 | } |
inezraharjo | 0:c31de740c873 | 66 | if (!one && two && !three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 67 | keyboard.keyCode('m'); |
inezraharjo | 0:c31de740c873 | 68 | } |
inezraharjo | 0:c31de740c873 | 69 | if (!one && two && !three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 70 | keyboard.keyCode('n'); |
inezraharjo | 0:c31de740c873 | 71 | } |
inezraharjo | 0:c31de740c873 | 72 | if (!one && two && !three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 73 | keyboard.keyCode('o'); |
inezraharjo | 0:c31de740c873 | 74 | } |
inezraharjo | 0:c31de740c873 | 75 | if (!one && !two && !three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 76 | keyboard.keyCode('p'); |
inezraharjo | 0:c31de740c873 | 77 | } |
inezraharjo | 0:c31de740c873 | 78 | if (!one && !two && !three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 79 | keyboard.keyCode('q'); |
inezraharjo | 0:c31de740c873 | 80 | } |
inezraharjo | 0:c31de740c873 | 81 | if (!one && !two && !three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 82 | keyboard.keyCode('r'); |
inezraharjo | 0:c31de740c873 | 83 | } |
inezraharjo | 0:c31de740c873 | 84 | if (one && !two && !three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 85 | keyboard.keyCode('s'); |
inezraharjo | 0:c31de740c873 | 86 | } |
inezraharjo | 0:c31de740c873 | 87 | if (one && !two && !three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 88 | keyboard.keyCode('t'); |
inezraharjo | 0:c31de740c873 | 89 | } |
inezraharjo | 0:c31de740c873 | 90 | if (!one && two && !three && !four && five && six){ |
inezraharjo | 0:c31de740c873 | 91 | keyboard.keyCode('u'); |
inezraharjo | 0:c31de740c873 | 92 | } |
inezraharjo | 0:c31de740c873 | 93 | if (!one && !two && !three && !four && five && six){ |
inezraharjo | 0:c31de740c873 | 94 | keyboard.keyCode('v'); |
inezraharjo | 0:c31de740c873 | 95 | } |
inezraharjo | 0:c31de740c873 | 96 | if (one && !two && three && !four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 97 | keyboard.keyCode('w'); |
inezraharjo | 0:c31de740c873 | 98 | } |
inezraharjo | 0:c31de740c873 | 99 | if (!one && two && !three && !four && five && !six){ |
inezraharjo | 0:c31de740c873 | 100 | keyboard.keyCode('x'); |
inezraharjo | 0:c31de740c873 | 101 | } |
inezraharjo | 0:c31de740c873 | 102 | if (!one && two && !three && !four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 103 | keyboard.keyCode('y'); |
inezraharjo | 0:c31de740c873 | 104 | } |
inezraharjo | 0:c31de740c873 | 105 | if (!one && two && !three && !four && !five && six){ |
inezraharjo | 0:c31de740c873 | 106 | keyboard.keyCode('z'); |
inezraharjo | 0:c31de740c873 | 107 | } |
inezraharjo | 0:c31de740c873 | 108 | if (one && two && !three && !four && five && six){ |
inezraharjo | 0:c31de740c873 | 109 | keyboard.keyCode(' '); |
inezraharjo | 0:c31de740c873 | 110 | } |
inezraharjo | 0:c31de740c873 | 111 | one = 1; |
inezraharjo | 0:c31de740c873 | 112 | two = 1; |
inezraharjo | 0:c31de740c873 | 113 | three = 1; |
inezraharjo | 0:c31de740c873 | 114 | four = 1; |
inezraharjo | 0:c31de740c873 | 115 | five = 1; |
inezraharjo | 0:c31de740c873 | 116 | six = 1; |
inezraharjo | 0:c31de740c873 | 117 | } |
inezraharjo | 0:c31de740c873 | 118 | wait(0.1); |
inezraharjo | 0:c31de740c873 | 119 | |
inezraharjo | 0:c31de740c873 | 120 | while (!pb || !pb2 || !pb3 || !pb4 || !pb5 || !pb6){ |
inezraharjo | 0:c31de740c873 | 121 | if (!pb){ |
inezraharjo | 0:c31de740c873 | 122 | one=0; |
inezraharjo | 0:c31de740c873 | 123 | } |
inezraharjo | 0:c31de740c873 | 124 | if (!pb2){ |
inezraharjo | 0:c31de740c873 | 125 | two=0; |
inezraharjo | 0:c31de740c873 | 126 | } |
inezraharjo | 0:c31de740c873 | 127 | if (!pb3){ |
inezraharjo | 0:c31de740c873 | 128 | three=0; |
inezraharjo | 0:c31de740c873 | 129 | } |
inezraharjo | 0:c31de740c873 | 130 | if (!pb4){ |
inezraharjo | 0:c31de740c873 | 131 | four=0; |
inezraharjo | 0:c31de740c873 | 132 | } |
inezraharjo | 0:c31de740c873 | 133 | if (!pb5){ |
inezraharjo | 0:c31de740c873 | 134 | five=0; |
inezraharjo | 0:c31de740c873 | 135 | } |
inezraharjo | 0:c31de740c873 | 136 | if (!pb6){ |
inezraharjo | 0:c31de740c873 | 137 | six=0; |
inezraharjo | 0:c31de740c873 | 138 | } |
inezraharjo | 0:c31de740c873 | 139 | |
inezraharjo | 0:c31de740c873 | 140 | } |
inezraharjo | 0:c31de740c873 | 141 | |
inezraharjo | 0:c31de740c873 | 142 | wait(0.1); |
inezraharjo | 0:c31de740c873 | 143 | |
inezraharjo | 0:c31de740c873 | 144 | } |
inezraharjo | 0:c31de740c873 | 145 | } |