Pages: [1]   Go Down
Author Topic: Triple Axis Accelerometer Values on  a  LCD  (Read 866 times)
0 Members and 1 Guest are viewing this topic.
St. Charles, MO, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 46
It Blinks Finally
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nothing real fancy.

I have plans for a using it as a accelerometer data logger for a road trip.  

[media]http://www.youtube.com/watch?v=Dh26qPCvtlw[/media]

Code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;

const int xPin = 3;                   // x-axis
const int yPin = 2;                   // y-axis
const int zPin = 1;                   // z-axis

void setup()
{
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH);
  Serial.begin(9600);
  
}

void loop()
{
  //Uncomment the lines below for Serial output
  
  //Serial.print("X=");
  //Serial.print(analogRead(xPin));  
  //Serial.print("\t");
  //Serial.print("Y=");
  //Serial.print(analogRead(yPin));  
  //Serial.print("\t");
  //Serial.print("Z=");
  //Serial.print(analogRead(zPin));  
  //delay(100);
  
  //Comment if not using a LCD.
  
  lcd.begin(2,16);              
  lcd.clear();                
  lcd.setCursor(0,0);  
  lcd.print("X= ");
  lcd.print(analogRead(xPin));  
  lcd.setCursor(10,0);          
  lcd.print("Y= ");
  lcd.print(analogRead(yPin));
  lcd.setCursor(5,1);          
  lcd.print("Z= ");
  lcd.print(analogRead(zPin));
  delay(100);
}
« Last Edit: January 29, 2010, 01:49:18 am by Rob_K » Logged

Pages: [1]   Go Up
Jump to: