last update 060306, by Guy Lee
The first thing needs to notice is that MMA7260Q operates on a 3.3V circuit.
You can check the detailed instruciton here, by Tom Igoe. However, I got a different schematic from Tom's. The one I used is showed as the image below, which comes from some other classmate's already-working circuit:

After connecting the serial port to PC, I could see three numbers which accordingly stand for hte data of X, Y and Z axis in serial communicator. Here I have a question: why is the initial data of MMA7260Q (131,124,186) instead of (0,0,0)? Is that because I didn't initialize the sensor? or something I missed?

Here presents the directions of three axes. However I find it's quite hard to trigger only one axis. I am still trying to figure out how the rotaion exactly changes the data. When I shake the sensor like the first picture below, for example, it seems that all three numbers, instead of only X value, get a big change.

Red wave stands for the change of X axis, green for Y and blue for Z. Circled parts meet the major change when I shake the sensor. (If the variation isn't obvious enough, you can adjust the Processing code and multiply the value by 2 or more)

[Processing code]
see here.
[PicBasic code]
DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 15 ' Set sampling time in uS tx var portc.6 rx var portc.7 n9600 con 16468 adcVar VAR word[3] ' Create variable to store results channel var byte byteVar var byte[3] inByte var byte ' set Sleep pin high: HIGH PORTB.7 ' Set PORTA to all input TRISA = %11111111 ' Set up ADCON1: ' AN3 = VREF+, all other analog pins are set to analog. ' See PIC 18F452 datasheet for details: ADCON1 = %10000010 main: ' wait for a byte: 'serin2 rx, n9600, [inByte] ' read all channels of the accelerometer: for channel = 0 to 2 ADCIN channel, adcVar[channel] ' convert to a byte: byteVar[channel] = adcVar[channel] /4 pause 20 next ' send results out the serial port: serout2 tx, n9600, [DEC byteVar[0],44,DEC byteVar[1],44,DEC byteVar[2],13,10] GoTo main