Parallax MX2125, Serial LCD

This is some code I modified to display the output of the Parallax Mx2125 accelerometer to the Parallax serial LCD.

const int TxPin = 6; // LCD transmit pin  
const int xPin = 2; // X output of the accelerometer
const int yPin = 3; // Y output of the accelerometer


#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

void setup() {
    
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
  pinMode(TxPin, OUTPUT);
  digitalWrite(TxPin, HIGH);
  mySerial.begin(9600);
  delay(100);
 
}

void loop()
{
   
  int pulseX, pulseY;  // variables to read the pulse widths:
  
  int accelerationX, accelerationY;  // variables to contain the resulting accelerations
  
 
  pulseX = pulseIn(xPin,HIGH);   // read pulse from x- and y-axes:
  pulseY = pulseIn(yPin,HIGH);
  
  accelerationX = ((pulseX / 10) - 500) * 8;
  accelerationY = ((pulseY / 10) - 500) * 8;

  mySerial.write(22); // turn on display with cusor off
  mySerial.write(17);  // turn on backlight        
  mySerial.print(accelerationX);
  mySerial.write(13); // carriage return
  mySerial.print(accelerationY); 
  mySerial.write(13); 
  delay(300);
  mySerial.write(12); // clear display must pause for 5ms
  delay(5);
}

This sketch was put together from code taken from the Arduino Playground. I am going to modify it further to help me run a few servos that I have. I couldn’t find this anywhere so I decided to slap this together myself. It wasn’t that hard to tell you the truth. I hope this helps out someone.