aboutsummaryrefslogtreecommitdiff
path: root/Arduino/ButtonMatrix
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2011-09-07 09:44:04 +0100
committerChristopher Baines <cbaines8@gmail.com>2011-09-07 09:44:04 +0100
commitba3448fb8093afd9d298cef1123a1bedfea13999 (patch)
treedc4ea674c977a5e76789146aa0de62e758078b9f /Arduino/ButtonMatrix
parentcfa29ad09cc9974a0a55e5b25bcc5f59a71d5950 (diff)
downloadpunchingbag-ba3448fb8093afd9d298cef1123a1bedfea13999.tar
punchingbag-ba3448fb8093afd9d298cef1123a1bedfea13999.tar.gz
Added LEDMatrix.pde, this should be used to test the first matrix only! (at the moment). Also added font, this can be used only with java 1.70 and an eclipse maintantice build?
Diffstat (limited to 'Arduino/ButtonMatrix')
-rwxr-xr-xArduino/ButtonMatrix/ButtonMatrix.pde28
1 files changed, 28 insertions, 0 deletions
diff --git a/Arduino/ButtonMatrix/ButtonMatrix.pde b/Arduino/ButtonMatrix/ButtonMatrix.pde
index 6ce18f4..1ed494c 100755
--- a/Arduino/ButtonMatrix/ButtonMatrix.pde
+++ b/Arduino/ButtonMatrix/ButtonMatrix.pde
@@ -3,6 +3,14 @@
const byte ROWS = 19;
const byte COLS = 8;
+
+// these constants describe the pins for the acellarometer . They won't change:
+const int groundpin = 18; // analog input pin 4 -- ground
+const int powerpin = 19; // analog input pin 5 -- voltage
+const int xpin = A3; // x-axis of the accelerometer
+const int ypin = A2; // y-axis
+const int zpin = A1; // z-axis (only on 3-axis models)
+
/* 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
@@ -33,6 +41,14 @@ void setup(){
Serial.begin(115200);
Serial.println("Go");
+ // Provide ground and power by using the analog inputs as normal
+ // digital pins. This makes it possible to directly connect the
+ // breakout board to the Arduino. If you use the normal 5V and
+ // GND pins on the Arduino, you can remove these lines.
+ pinMode(groundpin, OUTPUT);
+ pinMode(powerpin, OUTPUT);
+ digitalWrite(groundpin, LOW);
+ digitalWrite(powerpin, HIGH);
}
/* Send numbers back and forth to test the integrity of the serial communication
Computer sends the first byte
@@ -58,4 +74,16 @@ void loop(){
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(100);
}