Playing with the accelerometer software.....
Here is some information on using the Arduino with the IMU SEN-11072
see http://www.sparkfun.com/products/11072
The following tests the Accelerometer part (X Axis only) and allows for setting the offset and scaling
(A) - SEN-11072 IMU
(B) - Jaycar LCD display for the Arduino
http://www.jaycar.com.au/productView.asp?ID=XC4218&keywords=arduino&form=KEYWORD
Wiring connections are shown below (includes Gyro (pin A1) but not tested here)
(Make sure you connect the 3.3 volt output (and Gnd) to the Aref input!)
The output can be displayed on the (A) LCD or (B) the computer screen (using the serial monitor) and the Serial.println command as shown below
// Arduino - SEN-11072 Accelerometer Test and Setup Sketch // Connect accelerometer X axis output to the Arduino analog pin 5 // Upload, then open Serial monitor at 9600bps to see accelerometer value or use LCD display //define LCD (if used) #include <LiquidCrystal.h> LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 ); int angle = 0; // Variable used to store the angle read int offset; // Variable used to set mid point (approx to 512) - this is when the device is level (or flat....) int scale; // Variable used to adjust range 0 to 1023 - 0 for say +90 degrees and 1023 for -90 degrees int output; // Variable used to store the final X axis Acc value for use in the program void setup(){ Serial.begin(9600); // Start Serial monitor to print values analogReference(EXTERNAL); // Set the Arduino to use the Aref pin as its analog reference value (3.3v) } void loop(){ angle = analogRead(5); // Read the accelerometer X axis at analog pin A5 //Set these variables (will change for various Acc hardware devices) offset = -342.5; scale = 6; output = (angle + offset) * scale; // Output is the final value of X axis Acc Serial.println("Accelerometer: "); // Print the word "Accelerometer: " first Serial.println(output); // Then print the value of the variable "output" //output to LCD (if used) lcd.begin(16, 2); lcd.setCursor( 0, 0 ); lcd.print("Accelerometer:"); lcd.setCursor( 0, 1 ); lcd.print( output ); //delay delay(50); // update 20 times per second (1000 mS / 50 mS = 20) } |