aboutsummaryrefslogtreecommitdiff
path: root/Arduino/ButtonMatrix/ButtonMatrix.pde
diff options
context:
space:
mode:
Diffstat (limited to 'Arduino/ButtonMatrix/ButtonMatrix.pde')
-rwxr-xr-xArduino/ButtonMatrix/ButtonMatrix.pde110
1 files changed, 72 insertions, 38 deletions
diff --git a/Arduino/ButtonMatrix/ButtonMatrix.pde b/Arduino/ButtonMatrix/ButtonMatrix.pde
index 41ae6ab..99c879d 100755
--- a/Arduino/ButtonMatrix/ButtonMatrix.pde
+++ b/Arduino/ButtonMatrix/ButtonMatrix.pde
@@ -11,29 +11,48 @@ const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
const int selfTest = A0;
+const int id = 1;
+
/* Each of the buttons can be refered to by a number
- At the moment the byte overflow for the 127+ numbers is dealt with at the
- getKey time, but if a unsigned byte could be used here it would remove the need
- for the correction?
-*/
+ At the moment the byte overflow for the 127+ numbers is dealt with at the
+ getKey time, but if a unsigned byte could be used here it would remove the need
+ for the correction?
+ */
char keys[COLS][ROWS] = {
-{1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121, 129, 137, 145},
-{2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122, 130, 138, 146},
-{3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123, 131, 139, 147},
-{4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 132, 140, 148},
-{5, 13, 21, 29, 37, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125, 133, 141, 149},
-{6, 14, 22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 134, 142, 150},
-{7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 103, 111, 119, 127, 135, 143, 151},
-{8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152}
+ {
+ 1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121, 129, 137, 145 }
+ ,
+ {
+ 2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122, 130, 138, 146 }
+ ,
+ {
+ 3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123, 131, 139, 147 }
+ ,
+ {
+ 4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 132, 140, 148 }
+ ,
+ {
+ 5, 13, 21, 29, 37, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125, 133, 141, 149 }
+ ,
+ {
+ 6, 14, 22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126, 134, 142, 150 }
+ ,
+ {
+ 7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 103, 111, 119, 127, 135, 143, 151 }
+ ,
+ {
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152 }
};
-byte colPins[COLS] = {9, 8, 7, 6, 5, 4, 3, 2};
-byte rowPins[ROWS] = {14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42};
+byte colPins[COLS] = {
+ 9, 8, 7, 6, 5, 4, 3, 2};
+byte rowPins[ROWS] = {
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42};
/*
- Becuase of the diodes being fitted the WRONG WAY ROUND,
- the columns are rows and the rows are columns, have fun!
-*/
+ Becuase of the diodes being fitted the WRONG WAY ROUND,
+ the columns are rows and the rows are columns, have fun!
+ */
// ROW COL ROWS COLS
Keypad keypad = Keypad( makeKeymap(keys), colPins, rowPins, COLS, ROWS);
@@ -53,8 +72,8 @@ void setup(){
//digitalWrite(selfTest, HIGH);
}
/* Send numbers back and forth to test the integrity of the serial communication
- Computer sends the first byte
-*/
+ Computer sends the first byte
+ */
boolean runSerialTest() {
Serial.println("Begining Serial Test");
delay(10);
@@ -68,24 +87,39 @@ boolean runSerialTest() {
}
return true;
}
-
+
void loop(){
- char customKey = keypad.getKey();
- int customKeyInt = customKey;
- if (customKeyInt < 0) customKeyInt += 256;
- if (customKey != NO_KEY){
- Serial.println(customKeyInt);
- }
-
- // print the sensor values:
- Serial.print(analogRead(xpin));
- // print a tab between values:
- Serial.print("\t");
- Serial.print(analogRead(ypin));
- // print a tab between values:
- Serial.print("\t");
- Serial.print(analogRead(zpin));
- Serial.println();
- // delay before next reading:
- delay(10);
+ //if (Serial.peek() == 0x49) {
+ Serial.write(37);
+ //Serial.write(Serial.read());
+ /*if (Serial.read() == 0x44) {
+ Serial.write(id);
+ }*/
+ //} else {
+ // Serial.write(1);
+ //Serial.write(Serial.read());
+ //}
+
+ /*char customKey = keypad.getKey();
+ int customKeyInt = customKey;
+ if (customKeyInt < 0) customKeyInt += 256;
+ if (customKey != NO_KEY){
+ Serial.println(customKeyInt);
+ }
+
+ // print the sensor values:
+ Serial.print(analogRead(xpin));
+ // print a tab between values:
+ Serial.print("\t");
+ Serial.print(analogRead(ypin));
+ // print a tab between values:
+ Serial.print("\t");
+ Serial.print(analogRead(zpin));
+ Serial.println();
+ // delay before next reading:
+ //delay(10);*/
}
+
+
+
+