IDD Fall 2015
/
idd_fall15_hw2_inezraharjo_braille
Based on braile system for blind people.
Diff: main.cpp
- Revision:
- 0:c31de740c873
- Child:
- 1:7c1f8a60c3d4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Sep 13 00:04:17 2015 +0000 @@ -0,0 +1,145 @@ +#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; +// 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(' '); + } + 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); + + } +} \ No newline at end of file