Syntax: LCDIN Pin, Command, [InputData]
Receive data from an LCD display.
BS2p, BS2pe, and BS2px | |
Values for Pin | 0, 1, 8, or 9 |
I/O pin arrangement when Pin is 0 or 1 |
0 or 1 (depending on Pin) : LCD Enable (E) pin 2 : LCD Read/Write (R/W) pin 3 : LCD Register Select (RS) pin 4 - 7 : LCD Data Bus (DB4 - DB7, respectively) pins |
I/O pin arrangement when Pin is 8 or 9 |
8 or 9 (depending on Pin) : LCD Enable (E) pin 10 : LCD Read/Write (R/W) pin 11 : LCD Register Select (RS) pin 12 - 15 : LCD Data Bus (DB4 - DB7, respectively) pins |
Special Notes | LCDIN is designed to use the LCD's 4-bit mode only. |
Related Commands |
The three LCD commands (LCDCMD, LCDIN and LCDOUT) allow the BS2p, BS2pe, or BS2pe to interface directly to standard LCD displays that feature a Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16, and 4 x 20 character LCD displays. Note that LCDCMD, LCDIN and LCDOUT use a 4-bit interface to the LCD which requires a specific initialization sequence before LCDIN and LCDOUT can be used (see LCDCMD for initialization details).
The LCDIN command is used to send one instruction and then receive at least one data byte from the LCD's Character Generator RAM (CGRAM) or Display Data RAM (DDRAM). The following is an example of the LCDIN command:
char VAR Byte Main: LCDIN 1, 128, [char] STOP
The preceding example will read the character value at location 0 of the DDRAM. See the "Character Positioning" section, below, for more information.
The LCDIN command actually uses more than just the I/O pin specified by the Pin argument. The LCDIN command requires seven I/O pins. This is because the standard LCD displays have a parallel interface, rather than a serial one. The Pin argument can be the numbers 0, 1, 8, or 9 and will result in the use of the I/O pins shown above. Please refer to the LCDCMD command description for information on properly wiring the LCD display.
When the LCD is first powered-up, it will be in an unknown state and must be properly configured before sending commands like the one shown above. This process is known as initializing the LCD and is the first thing your program should do upon starting up. Please refer to the LCDCMD command description for information on properly initializing the LCD display.
The LCDIN command's InputData argument is similar to the SERIN command's InputData argument. This means data can be received as ASCII character values, decimal, hexadecimal and binary translations and string data as in the examples below (assume the LCD display has "Value: 3A:101" starting at the first character of the first line on the screen).
value VAR Byte(13) Main: LCDIN 1, 128, [value] ' receive ASCII code for "V" LCDIN 1, 128, [DEC value] ' receive the number 3 LCDIN 1, 128, [HEX value] ' receive the number $3A LCDIN 1, 128, [BIN value] ' receive the number %101 LCDIN 1, 128, [STR value\13] ' receive the string "Value: 3A:101"
The tables below list all the available conversion formatters and special formatters available to the LCDIN command. See the SERIN command for additional information and examples of their use.
Conversion Formatter | Type of Number | Numeric Characters Accepted | Notes |
DEC{1..5} | Decimal, optionally limited to 1 - 5 digits | 0 through 9 | 1 |
SDEC{1..5} | Signed decimal, optionally limited to 1 - 5 digits | -, 0 through 9 | 1,2 |
HEX{1..4} | Hexadecimal, optionally limited to 1 - 4 digits | 0 through 9, A through F | 1,3 |
SHEX{1..4} | Signed hexadecimal, optionally limited to 1 - 4 digits | -, 0 through 9, A through F | 1,2,3 |
IHEX{1..4} | Indicated hexadecimal, optionally limited to 1 - 4 digits | $, 0 through 9, A through F | 1,3,4 |
ISHEX{1..4} | Signed, indicated hexadecimal, optionally limited to 1 - 4 digits | -, $, 0 through 9, A through F | 1,2,3,4 |
BIN{1..16} | Binary, optionally limited to 1 - 16 digits | 0, 1 | 1 |
SBIN{1..16} | Signed binary, optionally limited to 1 - 16 digits | -, 0, 1 | 1,2 |
IBIN{1..16} | Indicated binary, optionally limited to 1 - 16 digits | %, 0, 1 | 1,4 |
ISBIN{1..16} | Signed, indicated binary, optionally limited to 1 - 16 digits | -, %, 0, 1 | 1,2,4 |
NUM | Generic numeric input; hex or binary number must be indicated | $, %, 0 through 9, A through F | 1,3,4 |
SNUM | Similar to NUM with value treated as signed with range -32768 to +32767 | -, $, %, 0 through 9, A through F | 1,2,3,4 |
Special Formatter | Action |
STR ByteArray \L {\E} | Input a character string of length L into an array. If specified, an end character E causes the string input to end before reaching length L. Remaining bytes are filled with 0s (zeros). |
WAITSTR ByteArray {\L} | Wait for a sequence of bytes matching a string stored in an array variable, optionally limited to L characters. If the optional L argument is left off, the end of the array-string must be marked by a byte containing a zero (0). |
SKIP Length | Ignore Length bytes of characters. |
SPSTR Length | Buffer Length bytes (up to 126) of serial characters to Scratchpad RAM, starting at location 0. Use GET to retrieve the characters. |
Some possible uses of the LCDIN command are 1) in combination with the LCDOUT command to store and read data from the unused DDRAM or CGRAM locations (as extra variable space), 2) to verify that the data from a previous LCDOUT command was received and processed properly by the LCD, and 3) to read character data from CGRAM for the purposes of modifying it and storing it as a custom character.
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.
8/8/2012