Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DebounceIn QEI mbed
Fork of idd_hw2_dpcinci_etchatext by
Revision 0:4005151fa9b1, committed 2014-09-21
- Comitter:
- dpcinci
- Date:
- Sun Sep 21 22:18:36 2014 +0000
- Commit message:
- published on sunday?
Changed in this revision
diff -r 000000000000 -r 4005151fa9b1 DebounceIn.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DebounceIn.lib Sun Sep 21 22:18:36 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
diff -r 000000000000 -r 4005151fa9b1 QEI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QEI.lib Sun Sep 21 22:18:36 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/aberk/code/QEI/#5c2ad81551aa
diff -r 000000000000 -r 4005151fa9b1 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Sep 21 22:18:36 2014 +0000
@@ -0,0 +1,507 @@
+#include "QEI.h"
+#include "mbed.h"
+#include "DebounceIn.h"
+
+Serial pc(USBTX, USBRX);
+//Use X4 encoding.
+//QEI wheel(p29, p30, NC, 624, QEI::X4_ENCODING);
+//Use X2 encoding by default.
+
+DebounceIn RButton(D6);
+DebounceIn LButton(D5);
+
+DigitalOut cLight1(D7);
+DigitalOut cLight2(D8);
+DigitalOut cLight3(D9);
+DigitalOut cLight4(D10);
+DigitalOut cLight5(D11);
+DigitalOut cLight6(D12);
+DigitalOut cLight7(D13);
+DigitalOut cLight8(D14);
+DigitalOut cLight9(D15);
+
+DigitalOut rLight1(A0);
+DigitalOut rLight2(A1);
+DigitalOut rLight3(A2);
+DigitalOut rLight4(A3);
+
+ QEI xWheel (D0, D2, NC, 624);
+ QEI yWheel (D3, D4, NC, 624);
+
+ int yPos;
+ int RowNum;
+ int RowEps = 3;
+ bool Rpress;
+
+ int xPos;
+ int ColNum = 5;
+ int ColEps = 3;
+ bool Lpress;
+
+ char *letter;
+
+
+int main() {
+
+ RButton.mode(PullUp);
+ LButton.mode(PullUp);
+
+ while(1){
+ yPos = yWheel.getPulses();
+ xPos = xWheel.getPulses();
+
+
+ Rpress = !RButton.read();
+ Lpress = !LButton.read();
+
+ //Get Column position
+ if(yPos < 2*RowEps){
+ RowNum = 1;
+ }
+ if(yPos > 2*RowEps && yPos < 4*RowEps){
+ RowNum = 2;
+ }
+ if(yPos > 4*RowEps && yPos < 6*RowEps){
+ RowNum = 3;
+ }
+ if(yPos > 6*RowEps){
+ RowNum = 4;
+ }
+
+
+ //Get Column position
+
+ if(xPos < -7*ColEps){
+ ColNum = 1;
+ }
+ if(xPos > -7*ColEps && xPos < -5*ColEps){
+ ColNum = 2;
+ }
+ if(xPos > -5*ColEps && xPos < -3*ColEps){
+ ColNum = 3;
+ }
+ if(xPos > -3*ColEps && xPos < -ColEps){
+ ColNum = 4;
+ }
+ if(xPos > -ColEps && xPos < ColEps){
+ ColNum = 5;
+ }
+ if(xPos > ColEps && xPos < 3*ColEps){
+ ColNum = 6;
+ }
+ if(xPos > 3*ColEps && xPos < 5*ColEps){
+ ColNum = 7;
+ }
+ if(xPos > 5*ColEps && xPos < 7*ColEps){
+ ColNum = 8;
+ }
+ if(xPos > 7*ColEps){
+ ColNum = 9;
+ }
+
+
+
+
+ //Set row LEDs
+
+ if(RowNum ==1){
+ rLight1 = 1;
+ rLight2 = 0;
+ rLight3 = 0;
+ rLight4 = 0;
+ }
+
+ if(RowNum ==2){
+ rLight1 = 0;
+ rLight2 = 1;
+ rLight3 = 0;
+ rLight4 = 0;
+ }
+
+ if(RowNum ==3){
+ rLight1 = 0;
+ rLight2 = 0;
+ rLight3 = 1;
+ rLight4 = 0;
+ }
+
+ if(RowNum ==4){
+ rLight1 = 0;
+ rLight2 = 0;
+ rLight3 = 0;
+ rLight4 = 1;
+ }
+ //set column leds
+
+ if(ColNum ==1){
+ cLight1 = 1;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 0;
+ }
+
+ if(ColNum ==2){
+ cLight1 = 0;
+ cLight2 = 1;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 0;
+ cLight8 = 0;
+ cLight9 = 0;
+ }
+
+ if(ColNum ==3){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 1;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 0;
+ cLight8 = 0;
+ cLight9 = 0;
+ }
+
+ if(ColNum ==4){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 1;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 0;
+ cLight8 = 0;
+ cLight9 = 0;
+ }
+
+ if(ColNum ==5){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 1;
+ cLight6 = 0;
+ cLight7 = 0;
+ cLight8 = 0;
+ cLight9 = 0;
+
+ }
+
+ if(ColNum ==6){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 1;
+ cLight7 = 0;
+ cLight8 = 0;
+ cLight9 = 0;
+
+ }
+
+ if(ColNum ==7){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 1;
+ cLight8 = 0;
+ cLight9 = 0;
+
+ }
+
+ if(ColNum ==8){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 0;
+ cLight8 = 1;
+ cLight9 = 0;
+
+ }
+
+ if(ColNum ==9){
+ cLight1 = 0;
+ cLight2 = 0;
+ cLight3 = 0;
+ cLight4 = 0;
+ cLight5 = 0;
+ cLight6 = 0;
+ cLight7 = 0;
+ cLight8 = 0;
+ cLight9 = 1;
+
+ }
+
+
+ // Set letter:
+
+
+ if(LButton){
+ if(RowNum == 1){
+ if(ColNum == 1){
+ letter = "q";
+ }
+ if(ColNum == 2){
+ letter = "z";
+ }
+ if(ColNum == 3){
+ letter = "x";
+ }
+ if(ColNum == 4){
+ letter = "c";
+ }
+ if(ColNum == 5){
+ letter = "v";
+ }
+ if(ColNum == 6){
+ letter = "b";
+ }
+ if(ColNum == 7){
+ letter = "n";
+ }
+ if(ColNum == 8){
+ letter = "m";
+ }
+ if(ColNum == 9){
+ letter = " ";
+ }
+ }
+
+ if(RowNum == 2){
+ if(ColNum == 1){
+ letter = "a";
+ }
+ if(ColNum == 2){
+ letter = "s";
+ }
+ if(ColNum == 3){
+ letter = "d";
+ }
+ if(ColNum == 4){
+ letter = "f";
+ }
+ if(ColNum == 5){
+ letter = "g";
+ }
+ if(ColNum == 6){
+ letter = "h";
+ }
+ if(ColNum == 7){
+ letter = "j";
+ }
+ if(ColNum == 8){
+ letter = "k";
+ }
+ if(ColNum == 9){
+ letter = "l";
+ }
+ }
+
+
+ if(RowNum == 3){
+ if(ColNum == 1){
+ letter = "w";
+ }
+ if(ColNum == 2){
+ letter = "e";
+ }
+ if(ColNum == 3){
+ letter = "r";
+ }
+ if(ColNum == 4){
+ letter = "t";
+ }
+ if(ColNum == 5){
+ letter = "y";
+ }
+ if(ColNum == 6){
+ letter = "u";
+ }
+ if(ColNum == 7){
+ letter = "i";
+ }
+ if(ColNum == 8){
+ letter = "o";
+ }
+ if(ColNum == 9){
+ letter = "p";
+ }
+ }
+
+ if(RowNum == 4){
+ if(ColNum == 1){
+ letter = "1";
+ }
+ if(ColNum == 2){
+ letter = "2";
+ }
+ if(ColNum == 3){
+ letter = "3";
+ }
+ if(ColNum == 4){
+ letter = "!";
+ }
+ if(ColNum == 5){
+ letter = "?";
+ }
+ if(ColNum == 6){
+ letter = ".";
+ }
+ if(ColNum == 7){
+ letter = "+";
+ }
+ if(ColNum == 8){
+ letter = "-";
+ }
+ if(ColNum == 9){
+ letter = "=";
+ }
+ }
+ }
+
+
+ if(!LButton){
+ if(RowNum == 1){
+ if(ColNum == 1){
+ letter = "Q";
+ }
+ if(ColNum == 2){
+ letter = "Z";
+ }
+ if(ColNum == 3){
+ letter = "X";
+ }
+ if(ColNum == 4){
+ letter = "C";
+ }
+ if(ColNum == 5){
+ letter = "V";
+ }
+ if(ColNum == 6){
+ letter = "B";
+ }
+ if(ColNum == 7){
+ letter = "N";
+ }
+ if(ColNum == 8){
+ letter = "M";
+ }
+ if(ColNum == 9){
+ letter = " ";
+ }
+ }
+
+ if(RowNum == 2){
+ if(ColNum == 1){
+ letter = "A";
+ }
+ if(ColNum == 2){
+ letter = "S";
+ }
+ if(ColNum == 3){
+ letter = "D";
+ }
+ if(ColNum == 4){
+ letter = "F";
+ }
+ if(ColNum == 5){
+ letter = "G";
+ }
+ if(ColNum == 6){
+ letter = "H";
+ }
+ if(ColNum == 7){
+ letter = "J";
+ }
+ if(ColNum == 8){
+ letter = "K";
+ }
+ if(ColNum == 9){
+ letter = "L";
+ }
+ }
+
+
+ if(RowNum == 3){
+ if(ColNum == 1){
+ letter = "W";
+ }
+ if(ColNum == 2){
+ letter = "E";
+ }
+ if(ColNum == 3){
+ letter = "R";
+ }
+ if(ColNum == 4){
+ letter = "T";
+ }
+ if(ColNum == 5){
+ letter = "Y";
+ }
+ if(ColNum == 6){
+ letter = "U";
+ }
+ if(ColNum == 7){
+ letter = "I";
+ }
+ if(ColNum == 8){
+ letter = "C";
+ }
+ if(ColNum == 9){
+ letter = "P";
+ }
+ }
+
+ if(RowNum == 4){
+ if(ColNum == 1){
+ letter = "1";
+ }
+ if(ColNum == 2){
+ letter = "2";
+ }
+ if(ColNum == 3){
+ letter = "3";
+ }
+ if(ColNum == 4){
+ letter = "!";
+ }
+ if(ColNum == 5){
+ letter = "?";
+ }
+ if(ColNum == 6){
+ letter = ".";
+ }
+ if(ColNum == 7){
+ letter = "+";
+ }
+ if(ColNum == 8){
+ letter = "-";
+ }
+ if(ColNum == 9){
+ letter = "=";
+ }
+ }
+ }
+
+
+ if(!RButton){
+ pc.printf("%s",letter);
+ wait(0.3);
+ }
+
+ wait(0.001);
+ }
+
+}
diff -r 000000000000 -r 4005151fa9b1 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Sep 21 22:18:36 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file
