diff options
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); } |