From ba3448fb8093afd9d298cef1123a1bedfea13999 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 7 Sep 2011 09:44:04 +0100 Subject: 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? --- Arduino/ButtonMatrix/ButtonMatrix.pde | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Arduino/ButtonMatrix') 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); } -- cgit v1.2.3