Overview

LCD wiring
==========

There are 16 pins on the 1602a LCD display (Hitachi HD44780U). These need to be
connected to the GPIOs of the Pi,

The following table shows the LCD pin, Pi Board number, Pi GPIO number, and the
explanation.

LCD     PI      GPIO    Comments
1       6               0V
2       2               +5V
3       6               Contrast (but 0 seems to be ok contrast)
4       16      23      RS
5       6               R/W (but we keep in write mode)
6       18      24      Enable
7       6               D0 (0V because we are in 4 bit mode)
8       6               D1 (0V because we are in 4 bit mode)
9       6               D2 (0V because we are in 4 bit mode)
10      6               D3 (0V because we are in 4 bit mode)
11      19      10      D4
12      23      11      D5
13      24      8       D6
14      26      7       D7
15      2               Backlight power (+5V)
16      6               Backlight ground (0V)


Don't use the random data sheets off the web because they are variable quality.
Just use the one from the manufacturer. E.g.:

http://www.stanford.edu/class/ee281/handouts/hd44780_lcd_controller_datasheet.pdf

See also

http://www.stanford.edu/class/ee281/handouts/lcd_tutorial.pdf


Sonar wiring
============

The Sonar device was a XL-EZ3. Unfortunately its RS232 output is inverted so we
need a transistor to invert it for the Pi.

The device has 7 pins:

Pins 1 to 4 are left open.
Pin 5 is data, connected to the base of a BC108.
Pin 6 is 3.3 power, connected to Board Pin 1 of Pi.
Pin 7 is ground, connect to Board Pin 6 of Pi.

See sonar_circuit.jpg for other connections.


Managing the code
=================

To deploy from the *host* linux box you need "fabric".

    http://fabfile.org

Install with

    sudo apt-get install fabric

Every function in fabfile.py is callable using:

    fab <function name>

So to provision the raspberry with deb packages and stop using the UART as a TTY
etc:

    fab provision

To flash the SD card:

    fab flash

There are some configuration parameters at the top of fabfile.py. E.g. to set
the IP address and the location of the card .img.

To run the LCD program:

    fab deploy
    fab lcd