diff options
author | Adam Martindale <awiamartindale@googlemail.com> | 2011-09-07 11:31:02 +0100 |
---|---|---|
committer | Adam Martindale <awiamartindale@googlemail.com> | 2011-09-07 11:31:02 +0100 |
commit | cd0fdd04f3108f61482919309b2a2da5c33f6872 (patch) | |
tree | 99710b299a02fa58382df101766892c0c3b679a7 /Arduino/ButtonMatrix | |
parent | dc16d95ed5a4b5f15f327cbe609414dc9e5d6225 (diff) | |
parent | ba3448fb8093afd9d298cef1123a1bedfea13999 (diff) | |
download | punchingbag-cd0fdd04f3108f61482919309b2a2da5c33f6872.tar punchingbag-cd0fdd04f3108f61482919309b2a2da5c33f6872.tar.gz |
Merge branch 'master' of gitorious.org:punchingbag/punchingbag
Diffstat (limited to 'Arduino/ButtonMatrix')
-rwxr-xr-x | Arduino/ButtonMatrix/ButtonMatrix.pde | 28 |
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); } |