Difference between revisions of "Serial enabled LCD backpack"
(→Code: added functions) |
(→Code) |
||
Line 56: | Line 56: | ||
=== Code === | === Code === | ||
− | |||
− | |||
− | |||
<source lang="C"> | <source lang="C"> | ||
//SerialLCD Functions | //SerialLCD Functions | ||
Line 119: | Line 116: | ||
} | } | ||
</source> | </source> | ||
− | |||
== See also == | == See also == |
Revision as of 19:52, 20 January 2010
The Serial Enabled LCD Backpack (SerLCD) is a product made by Sparkfun that allows control of a parallel based LCD over a single-wire serial interface. The SerLCD backpack takes care of all the HD44780 commands allowing seamless integration with any digital device that can communicate via a TTL serial line. The device is designed to handle a wide range of TTL serial baud rates, and currently supports 16 or 20 character wide screens with 2 or 4 lines of display.
Serial Enabled LCD Backpack (SerLCD) | |
---|---|
A version 2 backpack. | |
General Information | |
Manufacturer | SparkFun Electronics |
Current Version | 2.5 |
Average Price | $17 |
Specifications | |
Input Voltage | 5 V |
Max Input Voltage | 5.5 V |
Current Draw | 3 mA w/o backlight 60mA w/ backlight |
Clock Speed | 8 MHz |
Number of Positions | 16 |
Measurements | |
Length | 1.75 inches |
Width | 0.56 inches |
Communication
Communication with SerLCD requires 5V TTL serial at a default baud rate of 9600bps with 8 bits of data, 1 start bit, 1 stop bit, and no parity (8-N-1). You can adjust the baud to any standard rate between 2400 and 38400bps. The power, ground and RX pins are all broken out to a 3.5mm pitch screw terminal.
Pinout
- Ground (VSS)
- +5V (VDD)
- Contrast adjustment (V0)
- High/Low Register select signal (RS)
- High/Low Read/Write signal (R/W)
- High/Low Enable signal (E)
- High/Low bus line (DB0)
- High/Low bus line (DB1)
- High/Low bus line (DB2)
- High/Low bus line (DB3)
- High/Low bus line (DB4)
- High/Low bus line (DB5)
- High/Low bus line (DB6)
- High/Low bus line (DB7)
- +4.2V for LED (A)
- Power supply for BKL 0V (K)
Features
- New PIC 16F688 utilizes onboard UART for greater communication accuracy
- Adjustable baud rates of 2400, 4800, 9600 (default), 14400, 19200 and 38400
- Operational Backspace
- Greater processing speed at 10MHz
- Incoming buffer stores up to 80 characters
- Backlight transistor can handle up to 1A
- Pulse width modulation of backlight allows direct control of backlight brightness and current consumption
- Potentiometer to control contrast
- All surface mount design allows a backpack that is half the size of the original
- Faster boot-up time
- Boot-up display can be turned on/off via firmware
- User definable splash screen
Arduino
SerLCD works seamlessly with the Arduino with the option of using the default serial transmission port, or by creating a SoftwareSerial port.
Code
//SerialLCD Functions
void selectLine(int line) {
serCommand(); //command flag
switch( line ){
case 0:
lcd.print(128,BYTE); //puts the cursor at line 0 char 0
break;
case 1:
lcd.print(192,BYTE); //puts the cursor at line 0 char 0
break;
case 2:
lcd.print(148,BYTE); //puts the cursor at line 0 char 0
break;
case 3:
lcd.print(212,BYTE); //puts the cursor at line 0 char 0
break;
default:
selectLine(0); //defaults back to line 0
break;
}
}
void goTo(int position) { //position = line 1: 0-19, line 2: 20-39, etc, 79+ defaults back to 0
if (position<20){ Serial.print(0xFE, BYTE); //command flag
Serial.print((position+128), BYTE); //position
}else if (position<40){Serial.print(0xFE, BYTE); //command flag
Serial.print((position+128+64-20), BYTE); //position
}else if (position<60){Serial.print(0xFE, BYTE); //command flag
Serial.print((position+128+20-40), BYTE); //position
}else if (position<80){Serial.print(0xFE, BYTE); //command flag
Serial.print((position+128+84-60), BYTE); //position
} else { goTo(0); }
}
void clearLCD(){
Serial.print(0xFE, BYTE); //command flag
Serial.print(0x01, BYTE); //clear command.
}
void backlightOn(){ //turns on the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(157, BYTE); //light level.
}
void backlightOff(){ //turns off the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(128, BYTE); //light level for off.
}
void backlight50(){ //sets the backlight at 50% brightness
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(143, BYTE); //light level for off.
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.print(0xFE, BYTE);
}
See also