I just finished making a prototype of an accelerometer with a graphical LCD as the display. This is version 0.1, so I'd appreciate any feedback, including constructive criticism. You can see pictures of the build here and get the code that I used here.
The accelerometer has a few screens that display acceleration information. The first displays X & Y acceleration along with bar meters of each, the second displays longitudinal acceleration in a large font, the third displays X, Y, & Z acceleration along with bar meters of each, the fourth is a graphical display of X & Y acceleration, and the fifth shows maximum and minimum acceleration values for all three axes. Additionally, the backlight changes color in response to longitudinal acceleration.
Besides the components needed to build a standalone Arduino, I used the following major components for this build:
ST7565 graphic LCD
HEF4050BP non-inverting buffer (included w/ purchase of gLCD from Adafruit) for converting 5 V signals to 3.3 V
ADXL335 3-Axis Accelerometer
MCP1702 3.3 V regulator for powering the accelerometer and HEF4050BP
Three 330 Ohm resistors to put in series with the display backlight LEDs and 5 V PWM source
One tactile switch for switching between displays
One 120 Ohm resistor to put in series with the tactile switch
Universal prototype board
Initial setup of the ST7565 can be found in the Adafruit tutorial. For the sake of clarity, I'll briefly summarize what I did. First, I soldered some ~3" wires to each of the ST7565 inputs and outputs. The ST7565 that I have came with an RGB backlight rather than a monochromatic one, so it has 11 pinouts instead of 9 pinouts. The pinout is as follows:
B-: Cathode of blue backlight
G-: Cathode of green backlight
A+: Common RGB LED anode
R-: Cathode of red backlight
VDD: +3.3 V
SID: Serial input data
SCLK: Serial input clock
A0: Register select input pin
CS: Chip select
The ST7565 expects 3.3V at the inputs, so you need to use the 4050 non-inverting buffer to convert the 5V Arduino outputs to 3.3V. The Adafruit tutorial also covers this. Basically, the 4050 has a 3.3V input, a ground, and I/O pins. The I/O pins are adjacent to each other, so just connect a 5V signal to an input, and you'll see the same signal scaled down to 3.3V on the adjacent output.
Setting up the ADXL335 accelerometer is also pretty straightforward. I used a 3.3 V regulator to power it, although I don't see why you couldn't just use the 3.3 V output on the Arduino. I can't recall my reasoning for using the regulator, I just included it early on and it somehow carried through the design. Anyway, the ADXL335 has six pins:
Z: Z acceleration
Y: Y acceleration
X: X acceleration
3V: +3 V (can accept 1.8-3.6 V)
TST: Test pin (provides known response on X,Y, & Z pins when powered)
I grounded the test pin to prevent it from floating and causing erroneous readouts on the X,Y, & Z pins.
Here is how I had the components connected to the Arduino:
A1: Z accelerometer pin
A2: X accelerometer pin
A3: Y accelerometer pin (I switched the X & Y pins because I changed the orientation of the ADXL335 when I took it off the breadboard)
2: Tactile switch
3: (Will be connected to audio feedback in future rev)
5: LCD CS
6: LCD RST
7: LCD A0
8: LCD SCK
9: LCD B-
10: LCD R-
11: LCD G-
12: LCD MOSI
The LCD B-/R-/G- are connected to the Arduino via 330 Ohm resistors. The tactile switch is connected via a 120 Ohm resistor, with the other leg of the switch connected to +5 V.
That's pretty much it. The rest of the magic happens in the code, which you can find here (same as above). I'd like to reiterate my thanks to Oliver Kraus, who did a lot of work to make his u8g library work with the ST7565 display. I tried a few different libraries, and found this one to be the most useful.
Here are a few notes that may be of help, in no particular order:
-You can't display floats with a graphical LCD, although you can display integers and strings, among other things. I used the dtostrf function to convert floats to strings.
-The accelerometer output depends on the input voltage. The zero point will be half of the input voltage. The rate of change (in mV/g) is ideally 0.1 times the input voltage (in mV). So if you're supplying 3.3 V to the accelerometer, the board will output 1.65 V when not accelerating, and the output will change by 330 mV for every 1 g of acceleration.
-The u8g library can't display a box with negative dimensions relative to the origin of the box. To display a box that increases in size in the negative direction in proportion to negative acceleration, draw a larger box, then overwrite it with cleared pixels to get a box of the proper dimensions.
-The fonts in the library take up a fair amount of memory, and are only loaded as they're needed. If you want to use a wide variety of fonts, especially very large ones, make sure you have enough memory available.
-Currently, the display only updates once every 500 ms, and no other processes take place during the delay. The refresh rate will be decreased and a currentMillis/previousMillis loop will be added so that data collection and backlight updates will occur independent of display refresh.
-I'm going to include an audio feedback that changes pitch and volume in proportion to acceleration. This will, of course, be able to be switched on and off.
-It would be nice to add GPS data logging and write position/acceleration values to an SD card so that you can plot acceleration on a map at a later time. That will probably require a Mega, I would guess, although I haven't done much research on the matter yet.
-The current zeroing process requires that the accelerometer be level and accelerations are computed assuming that gravity was acting on the Z-axis only while zeroing. Future revs may include algorithms to eliminate this assumption.