Nanduino » 20x4 LCD Display
LCD displays are available from many manufacturers, but almost all of them use the same controller chip, the Hitachi HD44780. You can easily make a Nanduino talk to it, with just a few connecting wires. Here's one, using an external 5V supply:

You can download the code for talking to the LCD from here:
lcd.zip
The connections are straightforward. On the LCD module you will see 14 or 16 numbered pins.
- Connect pins 1, 3 & 5 to GND on the Nanduino.
- Connect pin 2 to VCC on the Nanduino.
- Connect pin 4 ("RS") to PD0 on the Nanduino.
- Connect pin 6 ("EN") to PC2 on the Nanduino.
- Leave the next four pins unconnected.
- Connect pin 11 ("DB4") to PC4 on the Nanduino.
- Connect pin 12 ("DB5") to PC5 on the Nanduino.
- Connect pin 13 ("DB6") to PC6 on the Nanduino.
- Connect pin 14 ("DB7") to PC7 on the Nanduino.
There is an example program which does some manipulation of the LCD in main.c, but you can use the functions declared in lcd.h:
// Initialise the LCD according to the HD44780 datasheet.
//
void lcdInit(void);
// Clear the screen, return the cursor to the top left.
//
void lcdClearScreen(void);
// Set the cursor position to the given coordinates without affecting the screen.
//
void lcdSetCursor(uint8 x, uint8 y);
// Replace the character at the current cursor position with the supplied character, except where
// it is 0x0A, in which case the LCD gets a linefeed.
//
void lcdPrintChar(char ch);
// Write the supplied NUL-terminated string to the current cursor position.
//
void lcdPrintString(const char *str);
// Write the supplied NUL-terminated PROGMEM string to the current cursor position.
//
void lcdPrintFlashString(const char *str);
Also, you can make a couple of customisations to the code. Have a look at the top of lcd.c:
// Comment this out to disable scrolling; this will cause text to wrap around to the top of the
// screen instead of the screen itself scrolling upwards. Disabling scrolling will save 61 bytes
// of RAM and about 450 bytes of flash.
//
#define SCROLLING
// These assume you have connected the LCD's EN to PC2, the LCD's RS to PD0, and the LCD's DB4..7
// to PC4..7. Replace these with your own implementations if you're connecting the LCD to other
// port pins.
//
static inline void writeTopNibbleAndAssertEnable(uint8 byte) {
PORTC &= 0x0F; // Clear top four bits; leave others unchanged
PORTC |= (byte & 0xF0) | 0x04; // Write top four bits and set EN high
}
static inline void clearEnable(void) {
PORTC &= 0xFB; // Clear enable
}
static inline void initPorts(void) {
DDRC |= 0xF4; // PC2 (EN), PC4..7 outputs
DDRD |= 0x01; // PD0 (RS) output
}
static inline void selectDataRegister(void) {
PORTD |= 0x01;
}
static inline void selectControlRegister(void) {
PORTD &= 0xFE;
}
As you can see, you can comment out SCROLLING to disable scrolling. With this commented out, rather than scrolling when the text runs off the bottom of the screen, the cursor will just wrap from the bottom right to the top left, overwriting what's already there. It will also save you 61 bytes of RAM and about 450 bytes of flash.
The second customisation you can make is if you choose to use other port lines instead of PD0, PC2, PC4..7, you can implement the above functions to use your alternatives.